summaryrefslogtreecommitdiffstats
path: root/modules/repository/generate.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-12-11 21:41:59 +0000
committerGitHub <noreply@github.com>2020-12-11 22:41:59 +0100
commit8e0548ed4a97470e1f4c6b61e398522fd1adb860 (patch)
treea2f9a08b4a3c4cf1b4aaeb68605343c216f01b09 /modules/repository/generate.go
parentf2f99a7d0c7ea3c667d254062d648ec387e3ea09 (diff)
downloadgitea-8e0548ed4a97470e1f4c6b61e398522fd1adb860.tar.gz
gitea-8e0548ed4a97470e1f4c6b61e398522fd1adb860.zip
Ensure that HEAD is updated to match default branch in template generation (#13948)
Fix #13912 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/repository/generate.go')
-rw-r--r--modules/repository/generate.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/repository/generate.go b/modules/repository/generate.go
index 0142d689d1..1ba457fb3a 100644
--- a/modules/repository/generate.go
+++ b/modules/repository/generate.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)
}