fix: use correct default branch for migrated wiki (#6754)
- Instead of getting the default branch of the 'code' repository, get the default branch of the wiki repository. - It's a bug of forgejo/forgejo#2264, likely caused by the confusion between `gitrepo` (the package name) and `gitRepo` (the git repo for the just migrated wiki repository). - Adjusted existing integration test. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6754 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
7579f25807
commit
59910a461d
2 changed files with 15 additions and 12 deletions
|
@ -15,7 +15,6 @@ import (
|
|||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/migration"
|
||||
|
@ -97,7 +96,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
|||
}
|
||||
defer gitRepo.Close()
|
||||
|
||||
branch, err := gitrepo.GetDefaultBranch(ctx, repo)
|
||||
branch, err := gitRepo.GetHEADBranch()
|
||||
if err != nil {
|
||||
log.Warn("Failed to get the default branch of a migrated wiki repo: %v", err)
|
||||
if err := util.RemoveAll(wikiPath); err != nil {
|
||||
|
@ -106,7 +105,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
|||
|
||||
return repo, err
|
||||
}
|
||||
repo.WikiBranch = branch
|
||||
repo.WikiBranch = branch.Name
|
||||
|
||||
if err := git.WriteCommitGraph(ctx, wikiPath); err != nil {
|
||||
return repo, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue