@@ -67,7 +67,9 @@ func (svc GithubService) GetChangedFiles(prNumber int) ([]string, error) {
67
67
for {
68
68
files , resp , err := svc .Client .PullRequests .ListFiles (context .Background (), svc .Owner , svc .RepoName , prNumber , & opts )
69
69
if err != nil {
70
- log .Fatalf ("error getting pull request files: %v" , err )
70
+ log .Printf ("error getting pull request: %v" , err )
71
+ return nil , fmt .Errorf ("error getting pull request: %v" , err )
72
+
71
73
}
72
74
73
75
for _ , file := range files {
@@ -91,7 +93,8 @@ func (svc GithubService) GetChangedFilesForCommit(owner string, repo string, com
91
93
for {
92
94
commit , resp , err := svc .Client .Repositories .GetCommit (context .Background (), owner , repo , commitID , & opts )
93
95
if err != nil {
94
- log .Fatalf ("error getting commitfiles: %v" , err )
96
+ log .Printf ("error getting commitfiles: %v" , err )
97
+ return nil , fmt .Errorf ("error getting commitfiles: %v" , err )
95
98
}
96
99
for _ , file := range commit .Files {
97
100
fileNames = append (fileNames , * file .Filename )
@@ -117,7 +120,8 @@ func (svc GithubService) ListIssues() ([]*ci.Issue, error) {
117
120
for {
118
121
issues , resp , err := svc .Client .Issues .ListByRepo (context .Background (), svc .Owner , svc .RepoName , opts )
119
122
if err != nil {
120
- log .Fatalf ("error getting pull request files: %v" , err )
123
+ log .Printf ("error getting pull request files: %v" , err )
124
+ return nil , fmt .Errorf ("error getting pull request files: %v" , err )
121
125
}
122
126
for _ , issue := range issues {
123
127
if issue .PullRequestLinks != nil {
@@ -216,7 +220,9 @@ func (svc GithubService) CreateCommentReaction(id string, reaction string) error
216
220
func (svc GithubService ) SetStatus (prNumber int , status string , statusContext string ) error {
217
221
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
218
222
if err != nil {
219
- log .Fatalf ("error getting pull request: %v" , err )
223
+ log .Printf ("error getting pull request : %v" , err )
224
+ return fmt .Errorf ("error getting pull request : %v" , err )
225
+
220
226
}
221
227
222
228
_ , _ , err = svc .Client .Repositories .CreateStatus (context .Background (), svc .Owner , svc .RepoName , * pr .Head .SHA , & github.RepoStatus {
@@ -230,12 +236,15 @@ func (svc GithubService) SetStatus(prNumber int, status string, statusContext st
230
236
func (svc GithubService ) GetCombinedPullRequestStatus (prNumber int ) (string , error ) {
231
237
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
232
238
if err != nil {
233
- log .Fatalf ("error getting pull request: %v" , err )
239
+ log .Printf ("error getting pull request: %v" , err )
240
+ return "" , fmt .Errorf ("error getting pull request: %v" , err )
234
241
}
235
242
236
243
statuses , _ , err := svc .Client .Repositories .GetCombinedStatus (context .Background (), svc .Owner , svc .RepoName , pr .Head .GetSHA (), nil )
237
244
if err != nil {
238
- log .Fatalf ("error getting combined status: %v" , err )
245
+ log .Printf ("error getting combined status: %v" , err )
246
+ return "" , fmt .Errorf ("error getting combined status: %v" , err )
247
+
239
248
}
240
249
241
250
return * statuses .State , nil
@@ -244,7 +253,8 @@ func (svc GithubService) GetCombinedPullRequestStatus(prNumber int) (string, err
244
253
func (svc GithubService ) MergePullRequest (prNumber int ) error {
245
254
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
246
255
if err != nil {
247
- log .Fatalf ("error getting pull request: %v" , err )
256
+ log .Printf ("error getting pull request: %v" , err )
257
+ return fmt .Errorf ("error getting pull request: %v" , err )
248
258
}
249
259
250
260
_ , _ , err = svc .Client .PullRequests .Merge (context .Background (), svc .Owner , svc .RepoName , prNumber , "auto-merge" , & github.PullRequestOptions {
@@ -272,26 +282,26 @@ func isMergeableState(mergeableState string) bool {
272
282
func (svc GithubService ) IsMergeable (prNumber int ) (bool , error ) {
273
283
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
274
284
if err != nil {
275
- log .Fatalf ("error getting pull request: %v" , err )
276
- return false , err
285
+ log .Printf ("error getting pull request: %v" , err )
286
+ return false , fmt . Errorf ( "error getting pull request: %v" , err )
277
287
}
278
288
return pr .GetMergeable () && isMergeableState (pr .GetMergeableState ()), nil
279
289
}
280
290
281
291
func (svc GithubService ) IsMerged (prNumber int ) (bool , error ) {
282
292
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
283
293
if err != nil {
284
- log .Fatalf ("error getting pull request: %v" , err )
285
- return false , err
294
+ log .Printf ("error getting pull request: %v" , err )
295
+ return false , fmt . Errorf ( "error getting pull request: %v" , err )
286
296
}
287
297
return * pr .Merged , nil
288
298
}
289
299
290
300
func (svc GithubService ) IsClosed (prNumber int ) (bool , error ) {
291
301
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
292
302
if err != nil {
293
- log .Fatalf ("error getting pull request: %v" , err )
294
- return false , err
303
+ log .Printf ("error getting pull request: %v" , err )
304
+ return false , fmt . Errorf ( "error getting pull request: %v" , err )
295
305
}
296
306
297
307
return pr .GetState () == "closed" , nil
@@ -317,8 +327,8 @@ func (svc GithubService) SetOutput(prNumber int, key string, value string) error
317
327
func (svc GithubService ) GetBranchName (prNumber int ) (string , string , error ) {
318
328
pr , _ , err := svc .Client .PullRequests .Get (context .Background (), svc .Owner , svc .RepoName , prNumber )
319
329
if err != nil {
320
- log .Fatalf ("error getting pull request: %v" , err )
321
- return "" , "" , err
330
+ log .Printf ("error getting pull request: %v" , err )
331
+ return "" , "" , fmt . Errorf ( "error getting pull request: %v" , err )
322
332
}
323
333
324
334
return pr .Head .GetRef (), pr .Head .GetSHA (), nil
0 commit comments