Skip to content

Commit 00a9044

Browse files
committed
Revert unnecessary changes
1 parent 95e2224 commit 00a9044

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

modules/gitrepo/branch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (str
3232
}
3333

3434
// SetDefaultBranch sets default branch of repository.
35-
func SetDefaultBranch(ctx context.Context, repo Repository, defaultBranch string) error {
35+
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error {
3636
_, _, err := git.NewCommand("symbolic-ref", "HEAD").
37-
AddDynamicArguments(git.BranchPrefix+defaultBranch).
37+
AddDynamicArguments(git.BranchPrefix+name).
3838
RunStdString(ctx, &git.RunOpts{Dir: repoPath(repo)})
3939
return err
4040
}

routers/private/default_branch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
2121
branch := ctx.PathParam("branch")
2222

2323
ctx.Repo.Repository.DefaultBranch = branch
24-
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, branch); err != nil {
24+
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
2525
ctx.JSON(http.StatusInternalServerError, private.Response{
2626
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
2727
})

services/repository/branch.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
463463
log.Error("CancelPreviousJobs: %v", err)
464464
}
465465

466-
// repo's default branch has been updated in git_model.RenameBranch
467-
err2 = gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch)
466+
err2 = gitrepo.SetDefaultBranch(ctx, repo, to)
468467
if err2 != nil {
469468
return err2
470469
}
@@ -651,7 +650,7 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, newB
651650
log.Error("CancelPreviousJobs: %v", err)
652651
}
653652

654-
return gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch)
653+
return gitrepo.SetDefaultBranch(ctx, repo, newBranchName)
655654
}); err != nil {
656655
return err
657656
}

services/repository/transfer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ func changeRepositoryName(ctx context.Context, repo *repo_model.Repository, newR
337337
}
338338

339339
if err = gitrepo.RenameRepository(ctx, repo,
340-
repo_model.StorageRepo(repo_model.RelativePath(repo.OwnerName, newRepoName)),
341-
); err != nil {
340+
repo_model.StorageRepo(repo_model.RelativePath(repo.OwnerName, newRepoName))); err != nil {
342341
return fmt.Errorf("rename repository directory: %w", err)
343342
}
344343

0 commit comments

Comments
 (0)