Skip to content

Commit

Permalink
fix(archive): warn only for non-default globs with no matches (#4013)
Browse files Browse the repository at this point in the history
Adjust the logging of warnings for unmatched globs to only show when the
glob is not a default. No warning will be output for the default globs
when there are no matching files.

These are defaults, by design, very generic.
We should not warn the user about them not finding anything, as that is
their expected behavior most of the time.
  • Loading branch information
caarlos0 committed May 16, 2023
1 parent 234e1d8 commit b5e8d6d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion internal/archivefiles/archivefiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func Eval(template *tmpl.Template, rlcp bool, files []config.File) ([]config.Fil
}

if len(files) == 0 {
log.WithField("glob", f.Source).Warn("no files matched")
if !f.Default {
// only log if its not a default glob, as those are usually
// very generic and are not really warnings for the user.
log.WithField("glob", f.Source).Warn("no files matched")
}
continue
}

Expand Down
12 changes: 6 additions & 6 deletions internal/pipe/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func (Pipe) Default(ctx *context.Context) error {
}
if len(archive.Files) == 0 {
archive.Files = []config.File{
{Source: "license*"},
{Source: "LICENSE*"},
{Source: "readme*"},
{Source: "README*"},
{Source: "changelog*"},
{Source: "CHANGELOG*"},
{Source: "license*", Default: true},
{Source: "LICENSE*", Default: true},
{Source: "readme*", Default: true},
{Source: "README*", Default: true},
{Source: "changelog*", Default: true},
{Source: "CHANGELOG*", Default: true},
}
}
if archive.NameTemplate == "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ type File struct {
Destination string `yaml:"dst,omitempty" json:"dst,omitempty"`
StripParent bool `yaml:"strip_parent,omitempty" json:"strip_parent,omitempty"`
Info FileInfo `yaml:"info,omitempty" json:"info,omitempty"`
Default bool `yaml:"-" json:"-"`
}

// FileInfo is the file info of a file.
Expand Down

0 comments on commit b5e8d6d

Please sign in to comment.