aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-06-08 18:10:59 +0800
committerGitHub <noreply@github.com>2023-06-08 10:10:59 +0000
commit0d47b0ab1de6ccbbead3cc7eae185fb3c50c47fe (patch)
treee08bb69cdfe0e8ffda67a1da916c6a3c2942cbde /services/repository
parent3bdd48016f659c440d6e8bb57386fab7ad7b357b (diff)
downloadgitea-0d47b0ab1de6ccbbead3cc7eae185fb3c50c47fe.tar.gz
gitea-0d47b0ab1de6ccbbead3cc7eae185fb3c50c47fe.zip
Remove duplicated functions when deleting a branch (#25128)
Extract from #22743 `DeleteBranch` will trigger a push update event, so that `pull_service.CloseBranchPulls` has been invoked twice and `AddDeletedBranch` is better to be moved to push update then even user delete a branch via git command, it will also be triggered. Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/branch.go9
-rw-r--r--services/repository/push.go3
2 files changed, 3 insertions, 9 deletions
diff --git a/services/repository/branch.go b/services/repository/branch.go
index 4027c75dc2..4e560786db 100644
--- a/services/repository/branch.go
+++ b/services/repository/branch.go
@@ -17,7 +17,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
repo_module "code.gitea.io/gitea/modules/repository"
- pull_service "code.gitea.io/gitea/services/pull"
)
// CreateNewBranch creates a new repository branch
@@ -181,10 +180,6 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
return err
}
- if err := pull_service.CloseBranchPulls(doer, repo.ID, branchName); err != nil {
- return err
- }
-
// Don't return error below this
if err := PushUpdate(
&repo_module.PushUpdateOptions{
@@ -199,9 +194,5 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
log.Error("Update: %v", err)
}
- if err := git_model.AddDeletedBranch(ctx, repo.ID, branchName, commit.ID.String(), doer.ID); err != nil {
- log.Warn("AddDeletedBranch: %v", err)
- }
-
return nil
}
diff --git a/services/repository/push.go b/services/repository/push.go
index 571eedccb3..e559d3f904 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -273,6 +273,9 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
// close all related pulls
log.Error("close related pull request failed: %v", err)
}
+ if err := git_model.AddDeletedBranch(db.DefaultContext, repo.ID, branch, opts.OldCommitID, pusher.ID); err != nil {
+ log.Warn("AddDeletedBranch: %v", err)
+ }
}
// Even if user delete a branch on a repository which he didn't watch, he will be watch that.