google / addlicense

A program which ensures source code files have copyright license headers by scanning directory patterns recursively
Apache License 2.0
724 stars 170 forks source link

provide fail-on-diff flag to enable checking licence headers #99

Closed developer-guy closed 2 years ago

developer-guy commented 2 years ago

We (w/@dentrax) thought that in scenarios such as checking license headers, we use addlicence tool like the following way:

  license-check:
    name: license boilerplate check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          go-version: '1.17.x'
      - name: Install addlicense
        run: go install github.com/google/addlicense@latest
      - name: Check license headers
        run: |
          set -e
          addlicense -l apache -c 'The Sigstore Authors' -v *
          git diff --exit-code

As you can see from the above GitHub Action definition, we use additional git commands to check that is there any leaked license headers in the codebase, so, what we are proposing is that we add this logic into addlicence tool with an additional flag-like --fail-on-diff.

developer-guy commented 2 years ago

would you mind assigning to us if you agree with this idea 🙋🏻‍♂️

developer-guy commented 2 years ago

kindly ping @willnorris

willnorris commented 2 years ago

Could you do this with the existing -check flag, which should return a non-zero status code if headers are missing ?

developer-guy commented 2 years ago

ah thank you, we missed that flag 🤦🏻‍♂️

willnorris commented 2 years ago

It sounds like -check will work for you, so I'm going to go ahead and close this. Feel free to reopen if it turns out that doesn't work.