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
4 changes: 2 additions & 2 deletions notifier/github/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func (g *CommitsService) lastOne(commits []string, revision string) (string, err
if revision == "" {
return "", errors.New("no revision specified")
}
if len(commits) == 0 {
return "", errors.New("no commits")
if len(commits) < 2 {
return "", errors.New("not enough commits")
}
// e.g.
// a0ce5bf 2018/04/05 20:50:01 (HEAD -> master, origin/master)
Expand Down
9 changes: 9 additions & 0 deletions notifier/github/commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ func TestCommitsLastOne(t *testing.T) {
lastRev: "",
ok: false,
},
{
// one commit
commits: []string{
"04e0917e448b662c2b16330fad50e97af16ff27a",
},
revision: "04e0917e448b662c2b16330fad50e97af16ff27a",
lastRev: "",
ok: false,
},
}

for _, testCase := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions notifier/gitlab/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func (g *CommitsService) lastOne(commits []string, revision string) (string, err
if revision == "" {
return "", errors.New("no revision specified")
}
if len(commits) == 0 {
return "", errors.New("no commits")
if len(commits) < 2 {
return "", errors.New("not enough commits")
}

return commits[1], nil
Expand Down
9 changes: 9 additions & 0 deletions notifier/gitlab/commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ func TestCommitsLastOne(t *testing.T) {
lastRev: "",
ok: false,
},
{
// one commit
commits: []string{
"04e0917e448b662c2b16330fad50e97af16ff27a",
},
revision: "04e0917e448b662c2b16330fad50e97af16ff27a",
lastRev: "",
ok: false,
},
}

for _, testCase := range testCases {
Expand Down