aboutsummaryrefslogtreecommitdiff
path: root/internal/rtree
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rtree')
-rw-r--r--internal/rtree/index.go2
-rw-r--r--internal/rtree/repo.go16
2 files changed, 13 insertions, 5 deletions
diff --git a/internal/rtree/index.go b/internal/rtree/index.go
index 7dd8d94..1f6799d 100644
--- a/internal/rtree/index.go
+++ b/internal/rtree/index.go
@@ -353,7 +353,7 @@ func (i *Index) ImportRepo(dirPath string) error {
if err != nil {
return err
}
- repo, err := NewRepoFromAbsolutePath(dirPath)
+ repo, err := NewRepoFromAbsolutePath(dirPath, true)
if err != nil {
return err
}
diff --git a/internal/rtree/repo.go b/internal/rtree/repo.go
index 91dd8da..9cb5eaf 100644
--- a/internal/rtree/repo.go
+++ b/internal/rtree/repo.go
@@ -49,7 +49,7 @@ func (r Remote) CompactURLs() []string {
// NewRepoFromAbsolutePath initializes a Repo instance by scanning the existing
// checkout at the given path.
-func NewRepoFromAbsolutePath(path string) (repo Repo, err error) {
+func NewRepoFromAbsolutePath(path string, normalizeRemoteURLs bool) (repo Repo, err error) {
repo.CheckoutPath, err = filepath.Rel(RootPath, path)
if err != nil {
return
@@ -70,7 +70,15 @@ func NewRepoFromAbsolutePath(path string) (repo Repo, err error) {
if match == nil {
continue
}
- name, url := match[1], ParseRemoteURL(match[2])
+ var (
+ name = match[1]
+ url RemoteURL
+ )
+ if normalizeRemoteURLs {
+ url = ParseRemoteURL(match[2])
+ } else {
+ url = RemoteURL(match[2]) // straight cast without processing
+ }
if remote, ok := repo.Remotes[name]; ok {
remote.URLs = append(remote.URLs, url)
repo.Remotes[name] = remote
@@ -115,7 +123,7 @@ func ForeachPhysicalRepo(action func(repo Repo) error) error {
}
//appears to be a repo
- repo, err := NewRepoFromAbsolutePath(path)
+ repo, err := NewRepoFromAbsolutePath(path, true)
if err == nil {
err = action(repo)
}
@@ -242,7 +250,7 @@ func (r Repo) ReformatRemoteURLs() error {
// NOTE: This is a bit convoluted because the specific case of updating URLs
// for a remote with multiple URLs requires multiple steps. First, we clear
// out all non-primary URLs, and then re-add them after updating the primary URL.
- actualRepo, err := NewRepoFromAbsolutePath(r.AbsolutePath())
+ actualRepo, err := NewRepoFromAbsolutePath(r.AbsolutePath(), false)
if err != nil {
return err
}