aboutsummaryrefslogtreecommitdiff
path: root/internal/rtree
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2021-09-10 08:17:18 +0000
committerGitHub <noreply@github.com>2021-09-10 08:17:18 +0000
commitcb398f58a5cb4f3e858fe60e84debde6ab58f7c8 (patch)
treefcddf00f60155e97485cf9b2122b65deb065249e /internal/rtree
parentd60ffba47afa7fc9c2816dd5e4b19fdbd9f06af5 (diff)
parent3b0030a6436351415da3865edf17bbe33657669b (diff)
downloadgofu-cb398f58a5cb4f3e858fe60e84debde6ab58f7c8.tar.gz
Merge pull request #7 from SuperSandro2000/absorbed-git-dir
rtree: fix error when running `rtree index` and absorbed .git dirs where indexed
Diffstat (limited to 'internal/rtree')
-rw-r--r--internal/rtree/index.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/rtree/index.go b/internal/rtree/index.go
index 64c8c74..b802ef8 100644
--- a/internal/rtree/index.go
+++ b/internal/rtree/index.go
@@ -132,12 +132,14 @@ func (i *Index) Rebuild() error {
fi, err := os.Stat(gitDirPath)
switch {
case err == nil:
- if fi.IsDir() {
+ // in a normal repo .git is a directory but when the repo is a submodule of another repo
+ // and the .git dir is absorbed then it is a file which contains the path to the real .git directory
+ if fi.IsDir() || fi.Mode().IsRegular() {
//everything okay with this repo
newRepos = append(newRepos, repo)
continue
}
- return fmt.Errorf("expected repository at %s, but is not a directory", gitDirPath)
+ return fmt.Errorf("expected repository at %s, but is not a directory or file", gitDirPath)
case !os.IsNotExist(err):
return err
}