aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@sap.com>2021-09-10 10:08:25 +0200
committerSandro Jäckel <sandro.jaeckel@sap.com>2021-09-10 10:10:27 +0200
commit3b0030a6436351415da3865edf17bbe33657669b (patch)
treefcddf00f60155e97485cf9b2122b65deb065249e
parentd60ffba47afa7fc9c2816dd5e4b19fdbd9f06af5 (diff)
downloadgofu-3b0030a6436351415da3865edf17bbe33657669b.tar.gz
rtree: fix error when running `rtree index` and absorbed .git dirs where indexed
The fixes the following error when /home/user/src/vscode-settings/ is a git repo with an absorbed .git dir where .git points to the real repo ``` $ rtree index repository /home/sandro/src/exampleA has been deleted -> delete from index !! expected repository at /home/user/src/exampleB/.git, but is not a directory ```
-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
}