Skip to content

Remove duplicated functions when deleting a branch #25128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions services/repository/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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
}
3 changes: 3 additions & 0 deletions services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down