Skip to content

Commit 34e089c

Browse files
committed
get/read operations in dry run mode should still be made
1 parent ef2c04b commit 34e089c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

internal/cmd/combine_prs.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ type RESTClientInterface interface {
2424
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) {
2525
// Move variable definitions outside the conditional blocks
2626
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+
}
2837

2938
if dryRun {
3039
Logger.Debug("Dry-run mode enabled. No changes will be made.")
@@ -33,16 +42,6 @@ func CombinePRsWithStats(ctx context.Context, graphQlClient *api.GraphQLClient,
3342

3443
// Skip branch creation and deletion if dry-run is enabled
3544
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-
4645
err = deleteBranch(ctx, restClient, repo, workingBranchName)
4746
if err != nil {
4847
Logger.Debug("Working branch not found, continuing", "branch", workingBranchName)

0 commit comments

Comments
 (0)