Skip to content

Commit

Permalink
fix last commit status since the order of ids are desc
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Sep 14, 2017
1 parent a0b3120 commit 2c706c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (status *CommitStatus) APIFormat() *api.Status {
return apiStatus
}

// CalcCommitStatus returns commit status state via some status
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
var lastStatus *CommitStatus
var state CommitStatusState
Expand All @@ -138,7 +138,7 @@ func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
}
if lastStatus == nil {
if len(statuses) > 0 {
lastStatus = statuses[len(statuses)-1]
lastStatus = statuses[0]
} else {
lastStatus = &CommitStatus{}
}
Expand Down

0 comments on commit 2c706c4

Please sign in to comment.