mirror of
https://github.com/vbatts/git-validation.git
synced 2024-11-22 16:15:40 +00:00
Merge pull request #41 from giuseppe/fix-empty-commit-range
git-validation: do not fail on an empty commit range
This commit is contained in:
commit
7b29366a0d
1 changed files with 4 additions and 0 deletions
|
@ -13,6 +13,7 @@ import (
|
||||||
// Commits returns a set of commits.
|
// Commits returns a set of commits.
|
||||||
// If commitrange is a git still range 12345...54321, then it will be isolated set of commits.
|
// If commitrange is a git still range 12345...54321, then it will be isolated set of commits.
|
||||||
// If commitrange is a single commit, all ancestor commits up through the hash provided.
|
// If commitrange is a single commit, all ancestor commits up through the hash provided.
|
||||||
|
// If commitrange is an empty commit range, then nil is returned.
|
||||||
func Commits(commitrange string) ([]CommitEntry, error) {
|
func Commits(commitrange string) ([]CommitEntry, error) {
|
||||||
cmdArgs := []string{"git", "--no-pager", "log", `--pretty=format:%H`, commitrange}
|
cmdArgs := []string{"git", "--no-pager", "log", `--pretty=format:%H`, commitrange}
|
||||||
if debug() {
|
if debug() {
|
||||||
|
@ -23,6 +24,9 @@ func Commits(commitrange string) ([]CommitEntry, error) {
|
||||||
logrus.Errorf("mm[git] cmd: %q", strings.Join(cmdArgs, " "))
|
logrus.Errorf("mm[git] cmd: %q", strings.Join(cmdArgs, " "))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if len(output) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
commitHashes := strings.Split(strings.TrimSpace(string(output)), "\n")
|
commitHashes := strings.Split(strings.TrimSpace(string(output)), "\n")
|
||||||
commits := make([]CommitEntry, len(commitHashes))
|
commits := make([]CommitEntry, len(commitHashes))
|
||||||
for i, commitHash := range commitHashes {
|
for i, commitHash := range commitHashes {
|
||||||
|
|
Loading…
Reference in a new issue