@@ -64,6 +64,11 @@ func main() {
64
64
Value : "" ,
65
65
Usage : "Forked user name on Github" ,
66
66
},
67
+ & cli.StringFlag {
68
+ Name : "gh-access-token" ,
69
+ Value : "" ,
70
+ Usage : "Access token for GitHub api request" ,
71
+ },
67
72
& cli.BoolFlag {
68
73
Name : "no-fetch" ,
69
74
Usage : "Set this flag to prevent fetch of remote branches" ,
@@ -169,9 +174,10 @@ func runBackport(c *cli.Context) error {
169
174
fmt .Printf ("* Backporting %s to %s as %s\n " , pr , localReleaseBranch , backportBranch )
170
175
171
176
sha := c .String ("cherry-pick" )
177
+ accessToken := c .String ("gh-access-token" )
172
178
if sha == "" {
173
179
var err error
174
- sha , err = determineSHAforPR (ctx , pr )
180
+ sha , err = determineSHAforPR (ctx , pr , accessToken )
175
181
if err != nil {
176
182
return err
177
183
}
@@ -427,13 +433,16 @@ func readVersion() string {
427
433
return strings .Join (split [:2 ], "." )
428
434
}
429
435
430
- func determineSHAforPR (ctx context.Context , prStr string ) (string , error ) {
436
+ func determineSHAforPR (ctx context.Context , prStr , accessToken string ) (string , error ) {
431
437
prNum , err := strconv .Atoi (prStr )
432
438
if err != nil {
433
439
return "" , err
434
440
}
435
441
436
442
client := github .NewClient (http .DefaultClient )
443
+ if accessToken != "" {
444
+ client = client .WithAuthToken (accessToken )
445
+ }
437
446
438
447
pr , _ , err := client .PullRequests .Get (ctx , "go-gitea" , "gitea" , prNum )
439
448
if err != nil {
0 commit comments