Browse Source
Ensure that HEAD is updated to match default branch in template generation (#13948)
Fix #13912
Signed-off-by: Andrew Thornton <art27@cantab.net>
mj-v1.14.3
zeripath
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
9 additions and
0 deletions
-
modules/repository/generate.go
-
modules/repository/init.go
|
|
@ -207,6 +207,14 @@ func generateGitContent(ctx models.DBContext, repo, templateRepo, generateRepo * |
|
|
|
} |
|
|
|
|
|
|
|
repo.DefaultBranch = templateRepo.DefaultBranch |
|
|
|
gitRepo, err := git.OpenRepository(repo.RepoPath()) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("openRepository: %v", err) |
|
|
|
} |
|
|
|
defer gitRepo.Close() |
|
|
|
if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { |
|
|
|
return fmt.Errorf("setDefaultBranch: %v", err) |
|
|
|
} |
|
|
|
if err = models.UpdateRepositoryCtx(ctx, repo, false); err != nil { |
|
|
|
return fmt.Errorf("updateRepository: %v", err) |
|
|
|
} |
|
|
|
|
|
@ -323,6 +323,7 @@ func initRepository(ctx models.DBContext, repoPath string, u *models.User, repo |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("openRepository: %v", err) |
|
|
|
} |
|
|
|
defer gitRepo.Close() |
|
|
|
if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { |
|
|
|
return fmt.Errorf("setDefaultBranch: %v", err) |
|
|
|
} |
|
|
|