-
Notifications
You must be signed in to change notification settings - Fork 169
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 exclude path feature #70
Conversation
@mco-gh @TomerAberbach do you have cycles to review this PR? |
@dlorenc whom shall we talk to have this PR reviewed/merged? |
I can take a look later today.
…On Wed, 28 Jul 2021 at 02:01, laurentsimon ***@***.***> wrote:
@dlorenc <https://github.com/dlorenc> whom shall we talk to have this PR
reviewed/merged?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFAXF3MKMB7II7QRPUFFW3TZ5JF5ANCNFSM42IWOGOA>
.
--
Marc Cohen
Web: mco.dev
Email: ***@***.***
Working with me: mco.dev/working-with-marc
Feedback: How am I doing? Provide anonymous feedback!
<https://www.increment.me/feedback/049628fd-7339-406d-9203-17d3ec8976bd/submit>
Q: Why is this email three sentences or less?
A: three.sentenc.es
|
@@ -52,6 +52,7 @@ var ( | |||
license = flag.String("l", "apache", "license type: apache, bsd, mit, mpl") | |||
licensef = flag.String("f", "", "license file") | |||
year = flag.String("y", fmt.Sprint(time.Now().Year()), "copyright year(s)") | |||
exclude = flag.String("e", "", "Files which exclude from check") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Files to exclude from check" seems more accurate
|
||
func (e *ExcludePath) Contains(path string) bool { | ||
for _, p := range e.paths { | ||
if p == path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work if someone specifies a relative path, e.g. /foo/bar, ./foo, ../foo/bar?
Perhaps you should canonicalize both strings to a full path to ensure you catch all those cases.
|
||
cmd := exec.Command(os.Args[0], | ||
"-test.run=TestExcludePath", | ||
"-y", "2018", "-e", origin1, origin1, origin2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions: 1) this is excluding a file. Isn't the more likely use case to exclude an entire dir tree? If so, could you add a test for that case? 2) Is the two appearances of origin1 a mistake or because you want to verify the logic handles duplicate paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In this implementation, I expect that only to accept filename. for example in current implementation, we get
/foo/bar
,/foo/bar/baz.txt
after filepath walk and configured/foo/bar
as exclude path then/foo/bar/baz.txt
won't be ignored. - It also includes dup path test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be beneficial to support directories: the main use case (and ours!) is dev teams removing test folders from the path. Test folders have a number of files that change over time, so it's cumbersome to update the command every time a new file is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - I think dirs is likely to be a far more valuable use case than enumerating individual files. If you do a prefix match then you get both, dirs and files, with a one line change.
Left comments.
…On Wed, 28 Jul 2021 at 08:59, Marc Cohen ***@***.***> wrote:
I can take a look later today.
On Wed, 28 Jul 2021 at 02:01, laurentsimon ***@***.***>
wrote:
> @dlorenc <https://github.com/dlorenc> whom shall we talk to have this PR
> reviewed/merged?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#70 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAFAXF3MKMB7II7QRPUFFW3TZ5JF5ANCNFSM42IWOGOA>
> .
>
--
Marc Cohen
Web: mco.dev
Email: ***@***.***
Working with me: mco.dev/working-with-marc
Feedback: How am I doing? Provide anonymous feedback!
<https://www.increment.me/feedback/049628fd-7339-406d-9203-17d3ec8976bd/submit>
Q: Why is this email three sentences or less?
A: three.sentenc.es
--
Marc Cohen
Web: mco.dev
Email: ***@***.***
Working with me: mco.dev/working-with-marc
Feedback: How am I doing? Provide anonymous feedback!
<https://www.increment.me/feedback/049628fd-7339-406d-9203-17d3ec8976bd/submit>
Q: Why is this email three sentences or less?
A: three.sentenc.es
|
gah, I did it again! I started working on a feature before realizing there is another PR in flight. Well in any event, it may be worth a look, since I ended up taking a bit more of a flexible option by using https://github.com/bmatcuk/doublestar. This allows us to deprecate the existing You can see the implementation here, and the test cases give a pretty clear example of what kinds of patterns would be possible: willnorris@6ac0919. This implementation may still suffer from the relative vs absolute path issue discussed here. I haven't looked closely enough yet to see if you all settled on a solution to that yet. |
I like this implementation. I'm less concerned about abs/rel paths than the
fact that #82 doesn't handle dirs, only files. Your PR handles both so I'm
inclined to use it. Give a little time to review before merging.
…On Thu, 29 Jul 2021 at 00:54, Will Norris ***@***.***> wrote:
gah, I did it again! I started working on a feature before realizing there
is another PR in flight. Well in any event, it may be worth a look, since I
ended up taking a bit more of a flexible option by using
https://github.com/bmatcuk/doublestar. This allows us to deprecate the
existing -skip which is pretty limited in only supporting file extensions.
You can see the implementation here, and the test cases give a pretty
clear example of what kinds of patterns would be possible: willnorris@
6ac0919
<willnorris@6ac0919>.
This implementation may still suffer from the relative vs absolute path
issue discussed here. I haven't looked closely enough yet to see if you all
settled on a solution to that yet.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFAXF5XGHNVBGBOVXUXMQ3T2CKEVANCNFSM42IWOGOA>
.
--
Marc Cohen
Web: mco.dev
Email: ***@***.***
Working with me: mco.dev/working-with-marc
Feedback: How am I doing? Provide anonymous feedback!
<https://www.increment.me/feedback/049628fd-7339-406d-9203-17d3ec8976bd/submit>
Q: Why is this email three sentences or less?
A: three.sentenc.es
|
It's also worth noting, and I only realized it later, that doublestar requires go1.16 because it's using the io/fs package. In #81, I have it testing against the last two minor releases, which would include 1.15. That's what we do for google/go-github, and what the Go project itself supports. Go typically releases at the end of July, so go1.17 should drop any day now. In that case, we might wait until go1.17 releases before adding in doublestar, if that's the approach you'd like to go with. Then we can continue to support the last two minor releases. |
Works for me.
…On Thu, 29 Jul 2021 at 16:02, Will Norris ***@***.***> wrote:
It's also worth noting, and I only realized it later, that doublestar
requires go1.16 because it's using thew io/fs package. In #81
<#81>, I have it testing against
the last two minor releases, which would include 1.15. That's what we do
for google/go-github, and I *think* what the Go project itself supports
(though I'm having trouble finding the docs). Go typically releases at the
end of July, so go1.17 should drop any day now. In that case, we might wait
until go1.17 releases before adding in doublestar, if that's the approach
you'd like to go with. Then we can continue to support the last two minor
releases.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFAXFZXGNCIJ7STWADXWQTT2FUR3ANCNFSM42IWOGOA>
.
--
Marc Cohen
Web: mco.dev
Email: ***@***.***
Working with me: mco.dev/working-with-marc
Feedback: How am I doing? Provide anonymous feedback!
<https://www.increment.me/feedback/049628fd-7339-406d-9203-17d3ec8976bd/submit>
Q: Why is this email three sentences or less?
A: three.sentenc.es
|
alternate implementation of this feature was added in #84 |
This PR introduces to skip check while filePath walk.