44 "context"
55 "fmt"
66 "log/slog"
7- "os"
8- "strconv"
97
108 "github.com/google/go-github/v50/github"
119 "github.com/sethvargo/go-githubactions"
@@ -23,21 +21,16 @@ type PrInfo struct {
2321 RepoName string
2422}
2523
26- func GetBackportPrInfo (ctx context.Context , log * slog.Logger , client * github.Client , ghctx * githubactions.GitHubContext ) (PrInfo , error ) {
27- prLabel := os .Getenv ("PR_LABEL" )
28- prNumber , _ := strconv .Atoi (os .Getenv ("PR_NUMBER" ))
29- repoOwner := os .Getenv ("REPO_OWNER" )
30- repoName := os .Getenv ("REPO_NAME" )
31-
24+ func GetBackportPrInfo (ctx context.Context , log * slog.Logger , client * github.Client , ghctx * githubactions.GitHubContext , repoOwner string , repoName string , prNumber int , prLabel string ) (PrInfo , error ) {
3225 log .Debug ("getting PR info" , "event_path" , ghctx .EventPath , "env_pr_label" , prLabel , "env_pr_number" , prNumber , "env_repo_owner" , repoOwner , "env_repo_name" , repoName )
3326
34- // First, try to use the API to get the PR info
27+ // Prefer using the env vars and API if they are set
3528 if prNumber != 0 && repoOwner != "" && repoName != "" {
3629 log .Debug ("getting PR info from API" )
3730 return getFromApi (ctx , client , prLabel , repoOwner , repoName , prNumber )
3831 }
3932
40- // Try to use event data if present
33+ // Fall back to event data if present
4134 if ghctx .EventPath != "" {
4235 log .Debug ("getting PR info from event" )
4336 return getFromEvent (ghctx )
0 commit comments