GetGoGitRepository was passing DetectDotGit:true to PlainOpenWithOptions
on a path that is already the resolved git directory (set from
'git rev-parse --git-dir' in LoadRepository). With detect on, go-git
looks for a .git entry inside that path; a bare repository has none, so
it returns ErrRepositoryNotExists and every caller (verifyCommitSignature,
tag verification) fails on bare repos.
DetectDotGit:false treats the path as the git dir directly and opens
both bare and working-tree layouts.
Adds tests covering GetGoGitRepository on bare repos including the
forge-conventional <name>.git layout.
Signed-off-by: Andrew Nesbitt <andrewnez@gmail.com>
This commit adds tests for uncovered error paths and edge cases in
pkg/gitinterface, and refactors existing tests for clarity:
- Add error path tests for CheckAndSetReference, SetReference,
DeleteReference, RefSpec, CanSign, VerifySignature,
TagUsingSpecificKey, GetAllFilesInTree, EnsureIsCommit,
GetTagTarget, ensureIsTag, and other helpers
- Inline error-case test functions into parent tests using t.Run
subtests for better organization
- Extract inline byte slices into named variables for readability
- Simplify temp directory usage where subdirectories are unnecessary
- Remove redundant parser-level error tests
- Format files with gofmt
Signed-off-by: dawgdevv <nraj02415@gmail.com>
This PR adds focused tests for error paths and edge cases across
pkg/gitinterface, raising coverage from 69.4% to 76.2%.
Files changed:
- references_test.go: TestAbsoluteReference with branch/tag/custom/ref lookups
- tag_test.go: TestEnsureIsTag, error paths for GetTagTarget and verifyTagSignature
- commit_test.go: TestEnsureIsCommit, error paths for commit inspection helpers
- object_test.go: Error paths for GetObjectType and GetObjectSize
- blob_test.go: Error path for ReadBlob with non-blob object
- status_test.go: Tests for Status errors and StatusCode helpers
- sync_test.go: Tests for WithFetchDepth, CreateRemote, push/fetch errors
- config_test.go: Error path for SetGitConfig
- utils_test.go: TestResetDueToError
Closes#1244
Signed-off-by: dawgdevv <nraj02415@gmail.com>