-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add licenses #367
Add licenses #367
Conversation
set -x | ||
git init | ||
git add --all | ||
git -c user.name="CI Bot" -c user.email="<>" commit -m "initial state" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does addlicense
need to make a commit? is that why you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't need to commit, just see the status.
I wrote this check a while ago for Bank of Anthos. I assume I got an error at some point when this was left out, but I can double check to see if it still works with this line removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I remember the context now: there is no git repo in the filesystem here originally, so I needed to create one and make an initial commit as a way of checking for changes after running the addlicence
command.
It's slightly hacky, but this was the cleanest solution I could think of. If you have other ideas for how to compare file system states, I'm open to other ideas
.github/workflows/ci.yml
Outdated
git add --all | ||
git -c user.name="CI Bot" -c user.email="<>" commit -m "initial state" | ||
addlicense ./ | ||
if [[ -n $(git status -s) ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also do simply do this: test -z "$(git status -s | tee /dev/stderr)"
right now you're not printing which files have a diff.
similarly git diff
would work fine here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the results are printed, since the set -x
flag is on. I think git status -s
is preferable to git diff
because we want to see the list of the files, not the full license content for each file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good. you can still remove this in this case by doing:
git init && git add --all && addlicense . && test -z $(git diff --name-only | tee /dev/stderr)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I find that a bit less readable, but I made the change
Google OSS projects are meant to have Google license headers in every file. This PR adds the missing headers, and adds a test to the CI system to catch future issues