Skip to content
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

Merged
merged 11 commits into from
Jul 15, 2020
Merged

Add licenses #367

merged 11 commits into from
Jul 15, 2020

Conversation

daniel-sanche
Copy link
Member

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

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 13, 2020
set -x
git init
git add --all
git -c user.name="CI Bot" -c user.email="<>" commit -m "initial state"
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Member Author

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

git add --all
git -c user.name="CI Bot" -c user.email="<>" commit -m "initial state"
addlicense ./
if [[ -n $(git status -s) ]]; then
Copy link
Contributor

@ahmetb ahmetb Jul 13, 2020

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.

Copy link
Member Author

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

Copy link
Contributor

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)

Copy link
Member Author

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

@daniel-sanche daniel-sanche merged commit c4d8670 into master Jul 15, 2020
@daniel-sanche daniel-sanche deleted the add-licenses branch July 15, 2020 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants