@@ -26,7 +26,7 @@ func New(githubAccessToken string) *githubManager {
26
26
return & githubManager {Context : ctx , Client : client , HttpClient : httpClient }
27
27
}
28
28
29
- func (gm * githubManager ) GetCommits (owner , repo , branch string , lastCommitsNumber int ) ([]Commit , error ) {
29
+ func (gm * githubManager ) GetCommits (owner , repo , branch string , lastCommitsNumber int , specificCheckName string ) ([]Commit , error ) {
30
30
if lastCommitsNumber > 100 || lastCommitsNumber < 1 {
31
31
return nil , & Error {Message : "lastCommitsNumber must be a number between 1 and 100" } // TODO maybe in future implement pagination
32
32
}
@@ -45,7 +45,7 @@ func (gm *githubManager) GetCommits(owner, repo, branch string, lastCommitsNumbe
45
45
return nil , err
46
46
}
47
47
48
- return hydrateCommits (q ), nil
48
+ return hydrateCommits (q , specificCheckName ), nil
49
49
}
50
50
51
51
func PickFirstParentCommits (fullCommitsList []Commit ) []Commit {
@@ -96,7 +96,7 @@ func (gm *githubManager) ChangeBranchHead(owner, repo, branch, sha string, force
96
96
return nil
97
97
}
98
98
99
- func hydrateCommits (q * githubQuery ) []Commit {
99
+ func hydrateCommits (q * githubQuery , specificCheckName string ) []Commit {
100
100
var fullCommitsList []Commit
101
101
for _ , edge := range q .Repository .Ref .Target .Commit .History .Edges {
102
102
var parents []Commit
@@ -107,11 +107,25 @@ func hydrateCommits(q *githubQuery) []Commit {
107
107
})
108
108
}
109
109
110
+ statusSuccess := false
111
+ // In case a commit check name is specified, it override and get priority over the commit cumulative status
112
+ if specificCheckName != "" {
113
+ for _ , checkSuite := range edge .Node .CheckSuites .Nodes {
114
+ for _ , checkRuns := range checkSuite .CheckRuns .Nodes {
115
+ if githubql .String (specificCheckName ) == checkRuns .Name {
116
+ statusSuccess = checkRuns .Conclusion == githubql .String (githubql .StatusStateSuccess )
117
+ }
118
+ }
119
+ }
120
+ } else {
121
+ statusSuccess = bool (edge .Node .StatusCheckRollup .State == githubql .String (githubql .StatusStateSuccess ))
122
+ }
123
+
110
124
fullCommitsList = append (fullCommitsList , Commit {
111
125
SHA : string (edge .Node .Oid ),
112
126
Message : string (edge .Node .Message ),
113
127
Parents : parents ,
114
- StatusSuccess : bool ( edge . Node . StatusCheckRollup . State == githubql . String ( githubql . StatusStateSuccess )) ,
128
+ StatusSuccess : statusSuccess ,
115
129
PushedDate : edge .Node .PushedDate .Time ,
116
130
})
117
131
}
0 commit comments