mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09: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:
co-authored by
wxiaoguang
parent
94a2c3ec18
commit
d47f9f37d6
@@ -492,12 +492,8 @@ func viewSummaryBranchFromRun(ctx context.Context, run *actions_model.ActionRun,
|
||||
Link: run.RefLink(),
|
||||
}
|
||||
if refName.IsBranch() {
|
||||
b, err := git_model.GetBranch(ctx, run.RepoID, refName.ShortName())
|
||||
if err != nil && !git_model.IsErrBranchNotExist(err) {
|
||||
log.Error("GetBranch: %v", err)
|
||||
} else if git_model.IsErrBranchNotExist(err) || (b != nil && b.IsDeleted) {
|
||||
branch.IsDeleted = true
|
||||
}
|
||||
refBranchExists, _ := git_model.IsBranchExist(ctx, run.RepoID, refName.ShortName())
|
||||
branch.IsDeleted = !refBranchExists
|
||||
}
|
||||
return branch
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user