@@ -24,7 +24,16 @@ type RESTClientInterface interface {
24
24
func CombinePRsWithStats (ctx context.Context , graphQlClient * api.GraphQLClient , restClient RESTClientInterface , repo github.Repo , pulls github.Pulls , command string , dryRun bool ) (combined []string , mergeConflicts []string , combinedPRLink string , err error ) {
25
25
// Move variable definitions outside the conditional blocks
26
26
workingBranchName := combineBranchName + workingBranchSuffix
27
- repoDefaultBranch := "main" // Default branch assumed for simulation
27
+
28
+ repoDefaultBranch , err := getDefaultBranch (ctx , restClient , repo )
29
+ if err != nil {
30
+ return nil , nil , "" , fmt .Errorf ("failed to get default branch: %w" , err )
31
+ }
32
+
33
+ baseBranchSHA , err := getBranchSHA (ctx , restClient , repo , repoDefaultBranch )
34
+ if err != nil {
35
+ return nil , nil , "" , fmt .Errorf ("failed to get SHA of main branch: %w" , err )
36
+ }
28
37
29
38
if dryRun {
30
39
Logger .Debug ("Dry-run mode enabled. No changes will be made." )
@@ -33,16 +42,6 @@ func CombinePRsWithStats(ctx context.Context, graphQlClient *api.GraphQLClient,
33
42
34
43
// Skip branch creation and deletion if dry-run is enabled
35
44
if ! dryRun {
36
- repoDefaultBranch , err = getDefaultBranch (ctx , restClient , repo )
37
- if err != nil {
38
- return nil , nil , "" , fmt .Errorf ("failed to get default branch: %w" , err )
39
- }
40
-
41
- baseBranchSHA , err := getBranchSHA (ctx , restClient , repo , repoDefaultBranch )
42
- if err != nil {
43
- return nil , nil , "" , fmt .Errorf ("failed to get SHA of main branch: %w" , err )
44
- }
45
-
46
45
err = deleteBranch (ctx , restClient , repo , workingBranchName )
47
46
if err != nil {
48
47
Logger .Debug ("Working branch not found, continuing" , "branch" , workingBranchName )
0 commit comments