Skip to content

Commit e5f19d0

Browse files
committed
Use specified default branch if it exists while generating git commits
1 parent 2c4c5d1 commit e5f19d0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/repository/generate.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r
184184
return fmt.Errorf("git remote add: %v", err)
185185
}
186186

187-
return initRepoCommit(ctx, tmpDir, repo, repo.Owner, templateRepo.DefaultBranch)
187+
// set default branch based on whether it's specified in the newly generated repo or not
188+
defaultBranch := repo.DefaultBranch
189+
if strings.TrimSpace(defaultBranch) == "" {
190+
defaultBranch = templateRepo.DefaultBranch
191+
}
192+
193+
return initRepoCommit(ctx, tmpDir, repo, repo.Owner, defaultBranch)
188194
}
189195

190196
func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *repo_model.Repository) (err error) {

0 commit comments

Comments
 (0)