Skip to content

Commit

Permalink
fix: walk the directory for .git folder to fetch HEAD commit OID (#111)
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant N Trivedi <siddhant@deepsource.io>
  • Loading branch information
siddhant-deepsource authored Mar 1, 2022
1 parent 24fccda commit 4178196
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion command/report/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ func gitGetHead(workspaceDir string) (string, error) {
// Fetches the latest commit hash using the command `git rev-parse HEAD`
// through go-git
func fetchHeadManually(directoryPath string) (string, error) {
gitOpts := &git.PlainOpenOptions{
DetectDotGit: true,
}

// Open a new repository targeting the given path (the .git folder)
repo, err := git.PlainOpen(directoryPath)
repo, err := git.PlainOpenWithOptions(directoryPath, gitOpts)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 4178196

Please sign in to comment.