Skip to content

Commit 4178196

Browse files
fix: walk the directory for .git folder to fetch HEAD commit OID (#111)
Signed-off-by: Siddhant N Trivedi <siddhant@deepsource.io>
1 parent 24fccda commit 4178196

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

command/report/git.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ func gitGetHead(workspaceDir string) (string, error) {
6363
// Fetches the latest commit hash using the command `git rev-parse HEAD`
6464
// through go-git
6565
func fetchHeadManually(directoryPath string) (string, error) {
66+
gitOpts := &git.PlainOpenOptions{
67+
DetectDotGit: true,
68+
}
69+
6670
// Open a new repository targeting the given path (the .git folder)
67-
repo, err := git.PlainOpen(directoryPath)
71+
repo, err := git.PlainOpenWithOptions(directoryPath, gitOpts)
6872
if err != nil {
6973
return "", err
7074
}

0 commit comments

Comments
 (0)