mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-02 19:09:39 +00:00
refactor(git): clarify GetBranch behavior to make it only gets an existing branch (#38662)
`GetBranch` silently returned soft-deleted branches, contradicting `IsBranchExist` and forcing callers to manually check `branch.IsDeleted` everywhere. Refactored it to `GetBranchExisting` to have a clear behavior: it only returns the existing branch. --------- Signed-off-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -410,7 +410,7 @@ func ToAPIPullRequests(ctx context.Context, baseRepo *repo_model.Repository, prs
|
||||
|
||||
baseBranch, ok := baseBranchCache[pr.BaseBranch]
|
||||
if !ok {
|
||||
baseBranch, err = git_model.GetBranch(ctx, baseRepo.ID, pr.BaseBranch)
|
||||
baseBranch, err = git_model.GetBranchExisting(ctx, baseRepo.ID, pr.BaseBranch)
|
||||
if err == nil {
|
||||
baseBranchCache[pr.BaseBranch] = baseBranch
|
||||
} else if !git_model.IsErrBranchNotExist(err) {
|
||||
|
||||
Reference in New Issue
Block a user