aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--repository/git.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/repository/git.go b/repository/git.go
index 17b2096f..3470958b 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -63,14 +63,16 @@ func (repo *GitRepo) runGitCommandInline(args ...string) error {
// and returns the corresponding GitRepo instance if it is.
func NewGitRepo(path string) (*GitRepo, error) {
repo := &GitRepo{Path: path}
- _, err := repo.runGitCommand("rev-parse")
- if err == nil {
- return repo, nil
- }
- if _, ok := err.(*exec.ExitError); ok {
+ stdout, err := repo.runGitCommand("rev-parse", "--show-toplevel")
+
+ if err != nil {
return nil, err
}
- return nil, err
+
+ // Fix the path to be sure we are at the root
+ repo.Path = stdout
+
+ return repo, nil
}
func InitGitRepo(path string) (*GitRepo, error) {