@@ -12,41 +12,41 @@ import (
12
12
"github.com/github/gh-combine/internal/github"
13
13
)
14
14
15
- func CombinePRs (ctx context.Context , graphQlClient * api.GraphQLClient , restClient * api.RESTClient , owner , repo string , pulls github.Pulls ) error {
15
+ func CombinePRs (ctx context.Context , graphQlClient * api.GraphQLClient , restClient * api.RESTClient , repo github. Repo , pulls github.Pulls ) error {
16
16
// Define the combined branch name
17
17
workingBranchName := combineBranchName + workingBranchSuffix
18
18
19
19
// Get the default branch of the repository
20
- repoDefaultBranch , err := getDefaultBranch (ctx , restClient , owner , repo )
20
+ repoDefaultBranch , err := getDefaultBranch (ctx , restClient , repo . Owner , repo . Repo )
21
21
if err != nil {
22
22
return fmt .Errorf ("failed to get default branch: %w" , err )
23
23
}
24
24
25
- baseBranchSHA , err := getBranchSHA (ctx , restClient , owner , repo , repoDefaultBranch )
25
+ baseBranchSHA , err := getBranchSHA (ctx , restClient , repo . Owner , repo . Repo , repoDefaultBranch )
26
26
if err != nil {
27
27
return fmt .Errorf ("failed to get SHA of main branch: %w" , err )
28
28
}
29
29
30
30
// Delete any pre-existing working branch
31
- err = deleteBranch (ctx , restClient , owner , repo , workingBranchName )
31
+ err = deleteBranch (ctx , restClient , repo . Owner , repo . Repo , workingBranchName )
32
32
if err != nil {
33
33
Logger .Debug ("Working branch not found, continuing" , "branch" , workingBranchName )
34
34
}
35
35
36
36
// Delete any pre-existing combined branch
37
- err = deleteBranch (ctx , restClient , owner , repo , combineBranchName )
37
+ err = deleteBranch (ctx , restClient , repo . Owner , repo . Repo , combineBranchName )
38
38
if err != nil {
39
39
Logger .Debug ("Combined branch not found, continuing" , "branch" , combineBranchName )
40
40
}
41
41
42
42
// Create the combined branch
43
- err = createBranch (ctx , restClient , owner , repo , combineBranchName , baseBranchSHA )
43
+ err = createBranch (ctx , restClient , repo . Owner , repo . Repo , combineBranchName , baseBranchSHA )
44
44
if err != nil {
45
45
return fmt .Errorf ("failed to create combined branch: %w" , err )
46
46
}
47
47
48
48
// Create the working branch
49
- err = createBranch (ctx , restClient , owner , repo , workingBranchName , baseBranchSHA )
49
+ err = createBranch (ctx , restClient , repo . Owner , repo . Repo , workingBranchName , baseBranchSHA )
50
50
if err != nil {
51
51
return fmt .Errorf ("failed to create working branch: %w" , err )
52
52
}
@@ -55,7 +55,7 @@ func CombinePRs(ctx context.Context, graphQlClient *api.GraphQLClient, restClien
55
55
var combinedPRs []string
56
56
var mergeFailedPRs []string
57
57
for _ , pr := range pulls {
58
- err := mergeBranch (ctx , restClient , owner , repo , workingBranchName , pr .Head .Ref )
58
+ err := mergeBranch (ctx , restClient , repo . Owner , repo . Repo , workingBranchName , pr .Head .Ref )
59
59
if err != nil {
60
60
// Check if the error is a 409 merge conflict
61
61
if isMergeConflictError (err ) {
@@ -73,21 +73,21 @@ func CombinePRs(ctx context.Context, graphQlClient *api.GraphQLClient, restClien
73
73
}
74
74
75
75
// Update the combined branch to the latest commit of the working branch
76
- err = updateRef (ctx , restClient , owner , repo , combineBranchName , workingBranchName )
76
+ err = updateRef (ctx , restClient , repo . Owner , repo . Repo , combineBranchName , workingBranchName )
77
77
if err != nil {
78
78
return fmt .Errorf ("failed to update combined branch: %w" , err )
79
79
}
80
80
81
81
// Delete the temporary working branch
82
- err = deleteBranch (ctx , restClient , owner , repo , workingBranchName )
82
+ err = deleteBranch (ctx , restClient , repo . Owner , repo . Repo , workingBranchName )
83
83
if err != nil {
84
84
Logger .Warn ("Failed to delete working branch" , "branch" , workingBranchName , "error" , err )
85
85
}
86
86
87
87
// Create the combined PR
88
88
prBody := generatePRBody (combinedPRs , mergeFailedPRs )
89
89
prTitle := "Combined PRs"
90
- err = createPullRequest (ctx , restClient , owner , repo , prTitle , combineBranchName , repoDefaultBranch , prBody )
90
+ err = createPullRequest (ctx , restClient , repo . Owner , repo . Repo , prTitle , combineBranchName , repoDefaultBranch , prBody )
91
91
if err != nil {
92
92
return fmt .Errorf ("failed to create combined PR: %w" , err )
93
93
}
0 commit comments