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

Option to list files that will be modified #28

Closed
mithun opened this issue Jan 23, 2020 · 6 comments · Fixed by #29
Closed

Option to list files that will be modified #28

mithun opened this issue Jan 23, 2020 · 6 comments · Fixed by #29

Comments

@mithun
Copy link
Contributor

mithun commented Jan 23, 2020

The capability to list files that will be modified, but without modifying them, will be very useful.

This will also allow addlicense to be used in CI environments, git-hooks, etc., to ensure licensing compliance.

@x1ddos
Copy link
Contributor

x1ddos commented Jan 25, 2020

#25 added a -v flag (verbose) to print files which are modified. You could use it to achieve the same effect.

But all that wouldn't help much in a CI environment because what you really want is a more clear signal to indicate whether at least one file is missing a license. You wouldn't want to inspect the output every time, especially in automated scripts and CIs.

What you probably want is for addlicense to exit with a specific code if at least 1 file missing a license. Then you could easily use that in hooks and CIs.

@x1ddos
Copy link
Contributor

x1ddos commented Jan 25, 2020

OTOH it isn't clear what zero exit code would mean then. Is it "ok, all files already have a license; none were modified" or "ok, added license where missing; all files now have a license".

Currently, there's no distinction and zero exit code simply means: ok, all files known to the program have a license now regardless of whether any of them were modified.

@mithun
Copy link
Contributor Author

mithun commented Jan 26, 2020

#25 added a -v flag (verbose) to print files which are modified. You could use it to achieve the same effect

Well, not really. The -v flag is still potentially modifying files.

What you probably want is for addlicense to exit with a specific code if at least 1 file missing a license. Then you could easily use that in hooks and CIs.

Yes.

Currently, there's no distinction and zero exit code simply means: ok, all files known to the program have a license now regardless of whether any of them were modified.

I agree.

This issue is for a new flag --check (or something appropriately named) that implements the following behavior: Running addlicense --check <pattern> must:

  • Never modify any files
  • Exit with zero (success) if all files in <pattern> have a license
  • Exit with non-zero (failure, exit code 1) if at least one file in the <pattern> requires modification to include a license text. Additionally, print such files to STDOUT.

@x1ddos
Copy link
Contributor

x1ddos commented Jan 28, 2020

Yeah, that's precisely it. Would you mind sending a pull request?

1 similar comment
@x1ddos
Copy link
Contributor

x1ddos commented Jan 28, 2020

Yeah, that's precisely it. Would you mind sending a pull request?

@mithun
Copy link
Contributor Author

mithun commented Jan 29, 2020

@x1ddos PR #29 is submitted

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 a pull request may close this issue.

2 participants