mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 03:18:55 +00:00
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
@ -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 {
|
||||
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")
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
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) {
|
||||
var fs []RejectByNameFunc
|
||||
// add patterns from file
|
||||
|
Loading…
Reference in New Issue
Block a user