From f553cfae2f957ddb63d4f8bdeb9c49a5194dc067 Mon Sep 17 00:00:00 2001 From: Song Gao Date: Mon, 4 May 2015 17:46:47 +0000 Subject: [PATCH] recursively search parent directory for vcs directory This adds support for projects where binaries stay in subdirectories of the project repo. --- vcs.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/vcs.go b/vcs.go index 743f7dc..db05c93 100644 --- a/vcs.go +++ b/vcs.go @@ -5,17 +5,23 @@ import ( "fmt" "os" "os/exec" + "path" "path/filepath" "strings" ) func repoDirExists(projPath, repoDir string) bool { - path := filepath.Join(projPath, repoDir) - info, err := os.Stat(path) - if err != nil { - return false + for ; projPath != path.Dir(projPath); projPath = path.Dir(projPath) { + path := filepath.Join(projPath, repoDir) + info, err := os.Stat(path) + if err != nil { + continue + } + if info.IsDir() { + return true + } } - return info.IsDir() + return false } // getId gets first line of commands output which should hold some VCS