-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 option to ignore files when adding. #4013
Conversation
License: MIT Signed-off-by: Łukasz Kurowski <crackcomm@gmail.com>
License: MIT Signed-off-by: Łukasz Kurowski <crackcomm@gmail.com>
commands/cli/parse.go
Outdated
} | ||
rulesFile = filepath.Join(cwd, ".gitignore") | ||
} else if err != nil { | ||
return nil, nil, u.ErrCast() |
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 would just return the err
here
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.
again, thanks
commands/cli/parse.go
Outdated
|
||
ignore, _, err := req.Option("ignore").Strings() | ||
if err != nil { | ||
return nil, nil, u.ErrCast() |
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.
just return nil, nil, err
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.
thanks
commands/files/filter.go
Outdated
|
||
// Filter - Returns true if file should be filtered. | ||
func (filter *Filter) Filter(fpath string) bool { | ||
if filter.Hidden && strings.HasPrefix(fpath, ".") { |
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 don't know if this would catch hidden files in recursive directories. We might want to use filepath.Base
here to get just the filename, then check if it has the dot prefix.
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.
Input to Filter
is always a filename actually.
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.
Oh? okay, then thats fine
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 discovered it should be the opposite - Hidden
true means include hidden files.
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.
changes mostly look good to me (noted a few small things). I would love to see these options tested out in a sharness test, you can probably either add more to test/sharness/t0042-something.sh or create a new test file just for testing these changes.
commands/cli/parse.go
Outdated
return parseArgs(inputs, stdin, argDefs, recursive, hidden, root) | ||
|
||
var rulesFile string | ||
if gitignore, _, err := req.Option("git-ignore").Bool(); gitignore { |
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.
Here we need to check for nil
's anyway.
commands/request.go
Outdated
@@ -334,7 +334,7 @@ func (r *request) ConvertOptions() error { | |||
} | |||
|
|||
kind := reflect.TypeOf(v).Kind() | |||
if kind != opt.Type() { | |||
if kind != opt.Type() && opt.Type() != Strings && kind != String { |
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.
Here it should be just kind != opt.Type() && opt.Type() != Strings
otherwise it doesn't convert numbers.
License: MIT Signed-off-by: Łukasz Kurowski <crackcomm@gmail.com>
Haven't reviewed the code itself, but I'm wondering why not stick with the convention of a .fooignore file? |
@lgierth I have no idea what is that. |
@lgierth did you mean to include rules from all |
Yeah let me clarify this a bit more, @whyrusleeping asked me to, too. Although the solution proposed looks okay on first sight, we haven't looked at any other options. What I'm missing here a bit is the evaluation and weighing of different ways of solving our need for having Here's another one, off the top of my head, one with an implicit .ipfsignore file.
This could be extended to also process an ipfsignore in Other options include an explicit ignore file ( I'm not saying the solution proposed here is bad, only that it's just the first and that we should look at more. |
I personally do not like the idea of additional |
Let me know if I can do anything to move this forward also #4013. |
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.
Support has been added #3643 (comment) |
Current usage:
Fixes #3643
Includes #4012
Breaking changes:
files.NewSerialFile