Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ func registerFlags(flags *pflag.FlagSet, b *flagBindings) {
flags.IntVar(intVar(&processor.HistoryDepth), "depth", 1000, "commit window size for git history reports; 0 means entire history (large repos may be slow)")
flags.BoolVar(boolVar(&processor.Timeline), "timeline", false, "render an over-time view of recent git history; with --by-author runs the author timeline, alone runs the languages timeline")
flags.IntVar(intVar(&processor.HistoryBuckets), "buckets", 60, "time-bucket resolution for the git timeline reports (default 60)")
flags.BoolVar(boolVar(&processor.ExpandGlobs), "expand-globs", false, "enable glob expansion on the files or directories")
// --no-fold-authors is read back via cmd.PersistentFlags().GetBool in Run, so
// its bound var is irrelevant; a throwaway sink is enough in both modes.
flags.BoolVar(new(bool), "no-fold-authors", false, "disable the name+email-domain identity folding fallback for git author reports (mailmap still applied)")
Expand Down
22 changes: 21 additions & 1 deletion processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ var HistoryBuckets = 60
// after the mailmap. Toggled off via --no-fold-authors.
var FoldAuthors = true

// ExpandGlobs enables glob expansion on the values of [DirFilePaths].
var ExpandGlobs = false

// DirFilePaths is not set via flags but by arguments following the flags for file or directory to process
var DirFilePaths = []string{}

Expand Down Expand Up @@ -905,6 +908,9 @@ func Process() {
fmt.Fprintf(os.Stderr, "warning: --report overrides --format=%s\n", Format)
}
parseReportSkip(ReportSkip)
if ExpandGlobs {
fmt.Fprintf(os.Stderr, "--report takes one positional argument; globs are not expanded")
}
if len(DirFilePaths) > 1 {
fmt.Fprintf(os.Stderr, "warning: --report only analyses the first positional path (%s); other paths ignored\n", DirFilePaths[0])
}
Expand Down Expand Up @@ -962,8 +968,22 @@ func Process() {
filePaths := []string{}
dirPaths := []string{}

allPaths := []string{}
if ExpandGlobs {
for _, pattern := range DirFilePaths {
matches, err := filepath.Glob(pattern)
if err != nil {
fmt.Fprintf(os.Stderr, "`%s` is an invalid pattern; skipping\n", pattern)
} else {
allPaths = append(allPaths, matches...)
}
}
} else {
allPaths = DirFilePaths
}

// Check if the paths or files added exist and exit if not
for _, f := range DirFilePaths {
for _, f := range allPaths {
fpath := filepath.Clean(f)

s, err := os.Stat(fpath)
Expand Down
Loading