0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-19 08:30:49 +02:00

Revert unnecessary changes

This commit is contained in:
Lunny Xiao 2025-03-28 19:13:07 -07:00
parent 95e2224841
commit 00a9044f41
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
4 changed files with 6 additions and 8 deletions

View File

@ -32,9 +32,9 @@ func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (str
}
// SetDefaultBranch sets default branch of repository.
func SetDefaultBranch(ctx context.Context, repo Repository, defaultBranch string) error {
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error {
_, _, err := git.NewCommand("symbolic-ref", "HEAD").
AddDynamicArguments(git.BranchPrefix+defaultBranch).
AddDynamicArguments(git.BranchPrefix+name).
RunStdString(ctx, &git.RunOpts{Dir: repoPath(repo)})
return err
}

View File

@ -21,7 +21,7 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
branch := ctx.PathParam("branch")
ctx.Repo.Repository.DefaultBranch = branch
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, branch); err != nil {
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
})

View File

@ -463,8 +463,7 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
log.Error("CancelPreviousJobs: %v", err)
}
// repo's default branch has been updated in git_model.RenameBranch
err2 = gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch)
err2 = gitrepo.SetDefaultBranch(ctx, repo, to)
if err2 != nil {
return err2
}
@ -651,7 +650,7 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, newB
log.Error("CancelPreviousJobs: %v", err)
}
return gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch)
return gitrepo.SetDefaultBranch(ctx, repo, newBranchName)
}); err != nil {
return err
}

View File

@ -337,8 +337,7 @@ func changeRepositoryName(ctx context.Context, repo *repo_model.Repository, newR
}
if err = gitrepo.RenameRepository(ctx, repo,
repo_model.StorageRepo(repo_model.RelativePath(repo.OwnerName, newRepoName)),
); err != nil {
repo_model.StorageRepo(repo_model.RelativePath(repo.OwnerName, newRepoName))); err != nil {
return fmt.Errorf("rename repository directory: %w", err)
}