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

How does pattern work? #38

Open
DarthHater opened this issue Apr 15, 2020 · 6 comments
Open

How does pattern work? #38

DarthHater opened this issue Apr 15, 2020 · 6 comments

Comments

@DarthHater
Copy link

Hello there,

I'm using this on nancy, and more or less, great tool!

However, it's a bit too nuclear with the . pattern, and adding licenses to files that we need to exclude (primarily GitHub templates, but we also don't really need licenses on files that really don't have IP (Dockerfile, gorelease.yml, etc...), so I was looking at using the pattern to basically only check and apply to **/*.go files, and maybe a couple others here and there. There isn't really much documentation I can see on pattern, so I figured I'd ask about usage, and then send y'all a PR with it included in the README for other goofballs like myself!

Cheers!

@DarthHater
Copy link
Author

I took a deeper look last night and it doesn't look like this is actually implemented? If that's the case @nblair and I were thinking of doing so, if y'all would welcome a PR!

@benjivesterby
Copy link

This seems to be working for me with ./*.go and just individual filenames. What were you trying @DarthHater

@DarthHater
Copy link
Author

Basically, I just want to exclude stuff like README.md, etc... that really don't need a license file. I'll give it a twirl with your suggestion!

@gtrevg
Copy link

gtrevg commented Oct 16, 2020

@DarthHater For reference, there's a similar project: https://github.com/elastic/go-licenser

Although it has less features, it'll walk the whole tree for you from the starting path you give it and will only apply the license to files that have the extension as defined by the -ext flag. I think it may only work for .go files, though.

I ended up having to use this other tool because //go:generate doesn't play nicely with wild cards.

jgehrcke added a commit to opstrace/opstrace that referenced this issue Dec 2, 2020
cd packages/app
find . -type d \( ! -name . \) -exec \
   bash -c '/home/jp/go/bin/addlicense -c "Opstrace, Inc." -l apache {}/*.tsx' \;

The pattern interpretation of addlicense
is dubious.
https://github.com/google/addlicense/blob/a0294312aa76d31c0bd7e49083d88a2a04d9b3d1/main.go
google/addlicense#38

I therefore constructed the above's command so that
addlicense *.tsx is invoked for each directory,
and so that the * is interpreted by the shell.

Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
jgehrcke added a commit to opstrace/opstrace that referenced this issue Dec 2, 2020
cd packages/app
find . -type d \( ! -name . \) -exec \
   bash -c '/home/jp/go/bin/addlicense -c "Opstrace, Inc." -l apache {}/*.tsx' \;

The pattern interpretation of addlicense
is dubious.
https://github.com/google/addlicense/blob/a0294312aa76d31c0bd7e49083d88a2a04d9b3d1/main.go
google/addlicense#38

I therefore constructed the above's command so that
addlicense *.tsx is invoked for each directory,
and so that the * is interpreted by the shell.

Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
@justmumu
Copy link

Guys,

Glob usage can be different due to terminal differences.
For example, if you are using zsh, **/*.go is just works. But you are on bash it does not by default.

I think the clearest way to use addlicense is using it with find command.
As an example to identical with **/*.go:
addlicense -check -v -l bsd -c "Bla Bla." $(find . -name "*.go" -type f -print0 | xargs -0)

@gtrevg
Copy link

gtrevg commented Dec 16, 2022

@justmumu -- We ended up using addlicense with the same technique you describe.

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

No branches or pull requests

4 participants