diff options
Diffstat (limited to 'internal/rtree/index.go')
| -rw-r--r-- | internal/rtree/index.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/rtree/index.go b/internal/rtree/index.go index 6b7bba8..201d4f9 100644 --- a/internal/rtree/index.go +++ b/internal/rtree/index.go @@ -152,16 +152,17 @@ func (i *Index) Rebuild() error { remoteURLs = append(remoteURLs, remote.URL.CompactURL()) } + repoPath := filepath.Join(RootPath, repo.CheckoutPath) var selection string if len(remoteURLs) == 0 { selection, err = cli.Interface.Query( - fmt.Sprintf("repository %s has been deleted; no remote to restore from", filepath.Join(RootPath, repo.CheckoutPath)), + fmt.Sprintf("repository %s has been deleted; no remote to restore from", repoPath), cli.Choice{Return: "d", Shortcut: 'd', Text: "delete from index"}, cli.Choice{Return: "s", Shortcut: 's', Text: "skip"}, ) } else { selection, err = cli.Interface.Query( - fmt.Sprintf("repository %s has been deleted", filepath.Join(RootPath, repo.CheckoutPath)), + fmt.Sprintf("repository %s has been deleted", repoPath), cli.Choice{Return: "r", Shortcut: 'r', Text: "restore from " + strings.Join(remoteURLs, " and ")}, cli.Choice{Return: "d", Shortcut: 'd', Text: "delete from index"}, cli.Choice{Return: "s", Shortcut: 's', Text: "skip"}, @@ -193,6 +194,13 @@ func (i *Index) Rebuild() error { //index new repos err := ForeachPhysicalRepo(func(newRepo Repo) error { repo, exists := existingRepos[newRepo.CheckoutPath] + + // if a repo has no remotes, repo is nil which rtree cannot parse back and doesn't make sense to add anyway + if repo == nil || repo.Remotes == nil { + fmt.Printf("repository %s has no remotes; skipping", filepath.Join(RootPath, newRepo.CheckoutPath)) + return nil + } + if exists { //update the existing index entry with the new remotes repo.Remotes = newRepo.Remotes |
