aboutsummaryrefslogtreecommitdiffstats
path: root/services/wiki/wiki.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/wiki/wiki.go')
-rw-r--r--services/wiki/wiki.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go
index 6f1ca120b0..1b921a44bd 100644
--- a/services/wiki/wiki.go
+++ b/services/wiki/wiki.go
@@ -370,6 +370,14 @@ func ChangeDefaultWikiBranch(ctx context.Context, repo *repo_model.Repository, n
return fmt.Errorf("unable to update database: %w", err)
}
+ oldDefBranch, err := gitrepo.GetWikiDefaultBranch(ctx, repo)
+ if err != nil {
+ return fmt.Errorf("unable to get default branch: %w", err)
+ }
+ if oldDefBranch == newBranch {
+ return nil
+ }
+
gitRepo, err := gitrepo.OpenWikiRepository(ctx, repo)
if errors.Is(err, util.ErrNotExist) {
return nil // no git repo on storage, no need to do anything else
@@ -378,14 +386,6 @@ func ChangeDefaultWikiBranch(ctx context.Context, repo *repo_model.Repository, n
}
defer gitRepo.Close()
- oldDefBranch, err := gitRepo.GetDefaultBranch()
- if err != nil {
- return fmt.Errorf("unable to get default branch: %w", err)
- }
- if oldDefBranch == newBranch {
- return nil
- }
-
err = gitRepo.RenameBranch(oldDefBranch, newBranch)
if err != nil {
return fmt.Errorf("unable to rename default branch: %w", err)