Skip to content

Commit 7b29366

Browse files
authored
Merge pull request #41 from giuseppe/fix-empty-commit-range
git-validation: do not fail on an empty commit range
2 parents 27e9409 + a269d9d commit 7b29366

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

git/commits.go

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
// Commits returns a set of commits.
1414
// If commitrange is a git still range 12345...54321, then it will be isolated set of commits.
1515
// If commitrange is a single commit, all ancestor commits up through the hash provided.
16+
// If commitrange is an empty commit range, then nil is returned.
1617
func Commits(commitrange string) ([]CommitEntry, error) {
1718
cmdArgs := []string{"git", "--no-pager", "log", `--pretty=format:%H`, commitrange}
1819
if debug() {
@@ -23,6 +24,9 @@ func Commits(commitrange string) ([]CommitEntry, error) {
2324
logrus.Errorf("mm[git] cmd: %q", strings.Join(cmdArgs, " "))
2425
return nil, err
2526
}
27+
if len(output) == 0 {
28+
return nil, nil
29+
}
2630
commitHashes := strings.Split(strings.TrimSpace(string(output)), "\n")
2731
commits := make([]CommitEntry, len(commitHashes))
2832
for i, commitHash := range commitHashes {

0 commit comments

Comments
 (0)