forked from TrueCloudLab/restic
rewrite: Fix check that an exclude pattern was passed
The old check did not consider files containing case insensitive excludes. The check is now implemented as a function of the excludePatternOptions struct to improve cohesion.
This commit is contained in:
parent
f175da2756
commit
537cfe2e4c
2 changed files with 5 additions and 1 deletions
|
@ -152,7 +152,7 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
|
||||||
}
|
}
|
||||||
|
|
||||||
func runRewrite(ctx context.Context, opts RewriteOptions, gopts GlobalOptions, args []string) error {
|
func runRewrite(ctx context.Context, opts RewriteOptions, gopts GlobalOptions, args []string) error {
|
||||||
if len(opts.ExcludeFiles) == 0 && len(opts.Excludes) == 0 && len(opts.InsensitiveExcludes) == 0 {
|
if opts.excludePatternOptions.Empty() {
|
||||||
return errors.Fatal("Nothing to do: no excludes provided")
|
return errors.Fatal("Nothing to do: no excludes provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -475,6 +475,10 @@ func initExcludePatternOptions(f *pflag.FlagSet, opts *excludePatternOptions) {
|
||||||
f.StringArrayVar(&opts.InsensitiveExcludeFiles, "iexclude-file", nil, "same as --exclude-file but ignores casing of `file`names in patterns")
|
f.StringArrayVar(&opts.InsensitiveExcludeFiles, "iexclude-file", nil, "same as --exclude-file but ignores casing of `file`names in patterns")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (opts *excludePatternOptions) Empty() bool {
|
||||||
|
return len(opts.Excludes) == 0 && len(opts.InsensitiveExcludes) == 0 && len(opts.ExcludeFiles) == 0 && len(opts.InsensitiveExcludeFiles) == 0
|
||||||
|
}
|
||||||
|
|
||||||
func collectExcludePatterns(opts excludePatternOptions) ([]RejectByNameFunc, error) {
|
func collectExcludePatterns(opts excludePatternOptions) ([]RejectByNameFunc, error) {
|
||||||
var fs []RejectByNameFunc
|
var fs []RejectByNameFunc
|
||||||
// add patterns from file
|
// add patterns from file
|
||||||
|
|
Loading…
Reference in a new issue