|
|
@ -64,6 +64,11 @@ func main() { |
|
|
|
Value: "", |
|
|
|
Value: "", |
|
|
|
Usage: "Forked user name on Github", |
|
|
|
Usage: "Forked user name on Github", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
&cli.StringFlag{ |
|
|
|
|
|
|
|
Name: "gh-access-token", |
|
|
|
|
|
|
|
Value: "", |
|
|
|
|
|
|
|
Usage: "Access token for GitHub api request", |
|
|
|
|
|
|
|
}, |
|
|
|
&cli.BoolFlag{ |
|
|
|
&cli.BoolFlag{ |
|
|
|
Name: "no-fetch", |
|
|
|
Name: "no-fetch", |
|
|
|
Usage: "Set this flag to prevent fetch of remote branches", |
|
|
|
Usage: "Set this flag to prevent fetch of remote branches", |
|
|
@ -169,9 +174,10 @@ func runBackport(c *cli.Context) error { |
|
|
|
fmt.Printf("* Backporting %s to %s as %s\n", pr, localReleaseBranch, backportBranch) |
|
|
|
fmt.Printf("* Backporting %s to %s as %s\n", pr, localReleaseBranch, backportBranch) |
|
|
|
|
|
|
|
|
|
|
|
sha := c.String("cherry-pick") |
|
|
|
sha := c.String("cherry-pick") |
|
|
|
|
|
|
|
accessToken := c.String("gh-access-token") |
|
|
|
if sha == "" { |
|
|
|
if sha == "" { |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
sha, err = determineSHAforPR(ctx, pr) |
|
|
|
sha, err = determineSHAforPR(ctx, pr, accessToken) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
@ -427,13 +433,16 @@ func readVersion() string { |
|
|
|
return strings.Join(split[:2], ".") |
|
|
|
return strings.Join(split[:2], ".") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func determineSHAforPR(ctx context.Context, prStr string) (string, error) { |
|
|
|
func determineSHAforPR(ctx context.Context, prStr, accessToken string) (string, error) { |
|
|
|
prNum, err := strconv.Atoi(prStr) |
|
|
|
prNum, err := strconv.Atoi(prStr) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return "", err |
|
|
|
return "", err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
client := github.NewClient(http.DefaultClient) |
|
|
|
client := github.NewClient(http.DefaultClient) |
|
|
|
|
|
|
|
if accessToken != "" { |
|
|
|
|
|
|
|
client = client.WithAuthToken(accessToken) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pr, _, err := client.PullRequests.Get(ctx, "go-gitea", "gitea", prNum) |
|
|
|
pr, _, err := client.PullRequests.Get(ctx, "go-gitea", "gitea", prNum) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|