From 2dd6ab16c2346a7d7ed8f9b740f33457573dfdd7 Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 1 Apr 2022 14:09:36 +0200 Subject: Add repo.GitDirPath() and use it --- internal/rtree/index.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'internal/rtree/index.go') diff --git a/internal/rtree/index.go b/internal/rtree/index.go index b802ef8..45b6522 100644 --- a/internal/rtree/index.go +++ b/internal/rtree/index.go @@ -128,8 +128,7 @@ func (i *Index) Rebuild() error { //check if existing index entries are still checked out var newRepos []*Repo for _, repo := range i.Repos { - gitDirPath := filepath.Join(repo.AbsolutePath(), ".git") - fi, err := os.Stat(gitDirPath) + fi, err := os.Stat(repo.GitDirPath()) switch { case err == nil: // in a normal repo .git is a directory but when the repo is a submodule of another repo @@ -139,7 +138,7 @@ func (i *Index) Rebuild() error { newRepos = append(newRepos, repo) continue } - return fmt.Errorf("expected repository at %s, but is not a directory or file", gitDirPath) + return fmt.Errorf("expected repository at %s, but is not a directory or file", repo.GitDirPath()) case !os.IsNotExist(err): return err } -- cgit v1.3.1 From 1c5cc4947add7cfc5fdbe0cce1e67450ce5d2bd3 Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 1 Apr 2022 14:09:58 +0200 Subject: rtree get: ignore .git when matching repos --- internal/rtree/index.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'internal/rtree/index.go') diff --git a/internal/rtree/index.go b/internal/rtree/index.go index 45b6522..226689a 100644 --- a/internal/rtree/index.go +++ b/internal/rtree/index.go @@ -226,7 +226,8 @@ func (i *Index) FindRepo(rawRemoteURL string, allowClone bool) (*Repo, error) { for _, repo := range i.Repos { isCandidate := false for _, remote := range repo.Remotes { - if remoteURL == remote.URL { + // be flexible about .git ending in remote + if remoteURL == remote.URL || remoteURL+".git" == remote.URL || remoteURL == remote.URL+".git" { return repo, nil } if basename == path.Base(remote.URL.CanonicalURL()) { -- cgit v1.3.1