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 possibility to update existing license header #60

Closed
wants to merge 4 commits into from

Conversation

oskarwojciski
Copy link

This change allows to update existing license headers, eg.

// Copyright 2018 Google LLC

to

// Copyright 2018-2021 Google LLC

To enable this mode flag -u must be set, example of use:

addlicense -c "CompanyName" -f LICENSE.tmpl  -v -u  ~/path_to_files/

It can be set up as commit pre-hook to change only files which are going to be commited:
.git/hooks/pre-commit:

git diff --staged --name-only -z | xargs -0  ./addlicense -c "CompanyName" -f LICENSE.tmpl -u

@willnorris
Copy link
Collaborator

Hey, thanks for the contribution!

I worry a bit about adding complexity to support a practice that (in my opinion) should probably be avoided anyway. I fully recognize that engineers at companies need to follow the guidance of their own legal departments, but it's worth noting that Google explicitly states that including the current year is optional, and at Twitter we actively discourage it (including only the earliest year in Copyright lines). It adds maintenance work because it has to be updated every year, with arguably no meaningful difference.

I'll certainly leave this open for discussion if other folks want to weight in, but I'm certainly wary of adding it to addlicense.

@oskarwojciski
Copy link
Author

@willnorris as you mentioned Google states that adding the current year is optional. This feature is also optional (if you want to update the year, you have to add the flag -u when running the program.
I see the value of adding it to the codebase, so companies using the google/addlicense may choose if they want to have the year updated or leave the earliest one.

@oskarwojciski
Copy link
Author

In our organization, we have also prepared GitHub action for our needs, which checks if the changed files contains the proper license header and if not, then update the files.

Here is the action source: https://github.com/nordcloud/addlicense/blob/master/action.yml
And example of the job is:

name: Action
on:
  pull_request:
    branches: [ master ]
jobs:
  licenses:
    name: Check licenses
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v2
      - id: changed-files
        uses: jitterbit/get-changed-files@v1
      - uses: nordcloud/addlicense@master
        with:
          directory-pattern: '${{ steps.changed-files.outputs.added_modified }}'
      - name: Commit changes
        uses: EndBug/add-and-commit@v7.0.0
        with:
          message: "Update license headers"
          add: '${{ steps.changed-files.outputs.added_modified }}'

@Shabirmean
Copy link

I agree with @willnorris. Unless the requirement is a clear need (for the purposes of the license to be valid), we should avoid overloading the tool. It is definitely a nice to have but these changes can complicate the simplicity of the tool which is generally available and used by many. I am siding to bank this change for now and consider it if this becomes a more general practice/need.

@oskarwojciski
Copy link
Author

😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants