mirror of
https://github.com/go-gitea/gitea.git
synced 2025-09-27 04:48:53 +00:00
Move some functions to gitrepo package (#35503)
This commit is contained in:
@@ -441,7 +441,7 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
|
||||
}
|
||||
|
||||
if err := git_model.RenameBranch(ctx, repo, from, to, func(ctx context.Context, isDefault bool) error {
|
||||
err2 := gitRepo.RenameBranch(from, to)
|
||||
err2 := gitrepo.RenameBranch(ctx, repo, from, to)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
@@ -552,9 +552,7 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
|
||||
return nil
|
||||
}
|
||||
|
||||
return gitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{
|
||||
Force: true,
|
||||
})
|
||||
return gitrepo.DeleteBranch(ctx, repo, branchName, true)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -27,8 +27,8 @@ import (
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
func cloneWiki(ctx context.Context, u *user_model.User, opts migration.MigrateOptions, migrateTimeout time.Duration) (string, error) {
|
||||
wikiPath := repo_model.WikiPath(u.Name, opts.RepoName)
|
||||
func cloneWiki(ctx context.Context, repo *repo_model.Repository, opts migration.MigrateOptions, migrateTimeout time.Duration) (string, error) {
|
||||
wikiPath := repo.WikiPath()
|
||||
wikiRemotePath := repo_module.WikiRemoteURL(ctx, opts.CloneAddr)
|
||||
if wikiRemotePath == "" {
|
||||
return "", nil
|
||||
@@ -59,7 +59,7 @@ func cloneWiki(ctx context.Context, u *user_model.User, opts migration.MigrateOp
|
||||
return "", err
|
||||
}
|
||||
|
||||
defaultBranch, err := git.GetDefaultBranch(ctx, wikiPath)
|
||||
defaultBranch, err := gitrepo.GetDefaultBranch(ctx, repo.WikiStorageRepo())
|
||||
if err != nil {
|
||||
cleanIncompleteWikiPath()
|
||||
return "", fmt.Errorf("failed to get wiki repo default branch for %q, err: %w", wikiPath, err)
|
||||
@@ -73,7 +73,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
||||
repo *repo_model.Repository, opts migration.MigrateOptions,
|
||||
httpTransport *http.Transport,
|
||||
) (*repo_model.Repository, error) {
|
||||
repoPath := repo_model.RepoPath(u.Name, opts.RepoName)
|
||||
repoPath := repo.RepoPath()
|
||||
|
||||
if u.IsOrganization() {
|
||||
t, err := organization.OrgFromUser(u).GetOwnerTeam(ctx)
|
||||
@@ -108,7 +108,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
||||
}
|
||||
|
||||
if opts.Wiki {
|
||||
defaultWikiBranch, err := cloneWiki(ctx, u, opts, migrateTimeout)
|
||||
defaultWikiBranch, err := cloneWiki(ctx, repo, opts, migrateTimeout)
|
||||
if err != nil {
|
||||
return repo, fmt.Errorf("clone wiki error: %w", err)
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
|
||||
if !repo.IsEmpty {
|
||||
if len(repo.DefaultBranch) == 0 {
|
||||
// Try to get HEAD branch and set it as default branch.
|
||||
headBranchName, err := git.GetDefaultBranch(ctx, repoPath)
|
||||
headBranchName, err := gitrepo.GetDefaultBranch(ctx, repo)
|
||||
if err != nil {
|
||||
return repo, fmt.Errorf("GetHEADBranch: %w", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user