mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-03 12:34:34 +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:
@@ -242,7 +242,7 @@ func TestPullSquashWithHeadCommitID(t *testing.T) {
|
||||
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
|
||||
|
||||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user1", Name: "repo1"})
|
||||
headBranch, err := git_model.GetBranch(t.Context(), repo1.ID, "master")
|
||||
headBranch, err := git_model.GetBranchExisting(t.Context(), repo1.ID, "master")
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, headBranch)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user