mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-01 15:14:16 +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:
@@ -25,7 +25,7 @@ func TestSyncRepoBranches(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
assert.Equal(t, "sha1", repo.ObjectFormatName)
|
||||
branch, err := git_model.GetBranch(t.Context(), 1, "master")
|
||||
branch, err := git_model.GetBranchExisting(t.Context(), 1, "master")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "master", branch.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user