Skip to content

Commit b0bcca0

Browse files
Implement --until log filter flag.
1 parent 0d64f09 commit b0bcca0

7 files changed

Lines changed: 36 additions & 2 deletions

File tree

dump.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func dump(
1717
paths []string,
1818
short bool,
1919
since string,
20+
until string,
2021
authors []string,
2122
nauthors []string,
2223
) (err error) {
@@ -36,6 +37,8 @@ func dump(
3637
short,
3738
"since",
3839
since,
40+
"until",
41+
until,
3942
"authors",
4043
authors,
4144
"nauthors",
@@ -49,6 +52,7 @@ func dump(
4952

5053
filters := git.LogFilters{
5154
Since: since,
55+
Until: until,
5256
Authors: authors,
5357
Nauthors: nauthors,
5458
}

hist.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func hist(
2525
showEmail bool,
2626
countMerges bool,
2727
since string,
28+
until string,
2829
authors []string,
2930
nauthors []string,
3031
) (err error) {
@@ -48,6 +49,8 @@ func hist(
4849
countMerges,
4950
"since",
5051
since,
52+
"until",
53+
until,
5154
"authors",
5255
authors,
5356
"nauthors",
@@ -67,13 +70,14 @@ func hist(
6770
populateDiffs := tallyOpts.IsDiffMode()
6871
filters := git.LogFilters{
6972
Since: since,
73+
Until: until,
7074
Authors: authors,
7175
Nauthors: nauthors,
7276
}
7377

7478
var end time.Time // Default is zero time, meaning use last commit
75-
if len(revs) == 1 && revs[0] == "HEAD" {
76-
// If no revs given, end timeline at current time
79+
if len(revs) == 1 && revs[0] == "HEAD" && len(until) == 0 {
80+
// If no revs or --until given, end timeline at current time
7781
end = time.Now()
7882
}
7983

internal/git/cmd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func run(
176176

177177
type LogFilters struct {
178178
Since string
179+
Until string
179180
Authors []string
180181
Nauthors []string
181182
}
@@ -188,6 +189,10 @@ func (f LogFilters) ToArgs() []string {
188189
args = append(args, "--since", f.Since)
189190
}
190191

192+
if f.Until != "" {
193+
args = append(args, "--until", f.Until)
194+
}
195+
191196
for _, author := range f.Authors {
192197
args = append(args, "--author", author)
193198
}

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Usage: git-who table [options...] [revisions...] [[--] paths...]
182182
*countMerges,
183183
*limit,
184184
*filterFlags.since,
185+
*filterFlags.until,
185186
filterFlags.authors,
186187
filterFlags.nauthors,
187188
)
@@ -256,6 +257,7 @@ Usage: git-who tree [options...] [revisions...] [[--] paths...]
256257
*showHidden,
257258
*countMerges,
258259
*filterFlags.since,
260+
*filterFlags.until,
259261
filterFlags.authors,
260262
filterFlags.nauthors,
261263
)
@@ -311,6 +313,7 @@ Usage: git-who hist [options...] [revisions...] [[--] paths...]
311313
*showEmail,
312314
*countMerges,
313315
*filterFlags.since,
316+
*filterFlags.until,
314317
filterFlags.authors,
315318
filterFlags.nauthors,
316319
)
@@ -337,6 +340,7 @@ func dumpCmd() command {
337340
paths,
338341
*short,
339342
*filterFlags.since,
343+
*filterFlags.until,
340344
filterFlags.authors,
341345
filterFlags.nauthors,
342346
)
@@ -363,6 +367,7 @@ func parseCmd() command {
363367
paths,
364368
*short,
365369
*filterFlags.since,
370+
*filterFlags.until,
366371
filterFlags.authors,
367372
filterFlags.nauthors,
368373
)
@@ -401,6 +406,7 @@ func isOnlyOne(flags ...bool) bool {
401406

402407
type filterFlags struct {
403408
since *string
409+
until *string
404410
authors flagutils.SliceFlag
405411
nauthors flagutils.SliceFlag
406412
}
@@ -410,6 +416,9 @@ func addFilterFlags(set *flag.FlagSet) *filterFlags {
410416
since: set.String("since", "", strings.TrimSpace(`
411417
Only count commits after the given date. See git-commit(1) for valid date formats
412418
`)),
419+
until: set.String("until", "", strings.TrimSpace(`
420+
Only count commits before the given date. See git-commit(1) for valid date formats
421+
`)),
413422
}
414423

415424
set.Var(&flags.authors, "author", strings.TrimSpace(`

parse.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func parse(
1717
paths []string,
1818
short bool,
1919
since string,
20+
until string,
2021
authors []string,
2122
nauthors []string,
2223
) (err error) {
@@ -36,6 +37,8 @@ func parse(
3637
short,
3738
"since",
3839
since,
40+
"until",
41+
until,
3942
"authors",
4043
authors,
4144
"nauthors",
@@ -49,6 +52,7 @@ func parse(
4952

5053
filters := git.LogFilters{
5154
Since: since,
55+
Until: until,
5256
Authors: authors,
5357
Nauthors: nauthors,
5458
}

table.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func table(
4242
countMerges bool,
4343
limit int,
4444
since string,
45+
until string,
4546
authors []string,
4647
nauthors []string,
4748
) (err error) {
@@ -69,6 +70,8 @@ func table(
6970
limit,
7071
"since",
7172
since,
73+
"until",
74+
until,
7275
"authors",
7376
authors,
7477
"nauthors",
@@ -88,6 +91,7 @@ func table(
8891
populateDiffs := tallyOpts.IsDiffMode()
8992
filters := git.LogFilters{
9093
Since: since,
94+
Until: until,
9195
Authors: authors,
9296
Nauthors: nauthors,
9397
}

tree.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func tree(
4747
showHidden bool,
4848
countMerges bool,
4949
since string,
50+
until string,
5051
authors []string,
5152
nauthors []string,
5253
) (err error) {
@@ -74,6 +75,8 @@ func tree(
7475
countMerges,
7576
"since",
7677
since,
78+
"until",
79+
until,
7780
"authors",
7881
authors,
7982
"nauthors",
@@ -95,6 +98,7 @@ func tree(
9598

9699
filters := git.LogFilters{
97100
Since: since,
101+
Until: until,
98102
Authors: authors,
99103
Nauthors: nauthors,
100104
}

0 commit comments

Comments
 (0)