diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2017-10-06 22:35:24 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2017-10-06 22:35:24 +0200 |
| commit | 28115d8776a952d9a0c32cf639cdffb2eff19ca2 (patch) | |
| tree | ade552691e197c7619cdf452903a707e45ad951e /pkg/prompt/pwd.go | |
| parent | 1be905eb3b00bb4ebb09de7b139e7d93eed54c92 (diff) | |
| download | gofu-28115d8776a952d9a0c32cf639cdffb2eff19ca2.tar.gz | |
fix handling of Git submodules
Diffstat (limited to 'pkg/prompt/pwd.go')
| -rw-r--r-- | pkg/prompt/pwd.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/prompt/pwd.go b/pkg/prompt/pwd.go index 969a8ce..1b93987 100644 --- a/pkg/prompt/pwd.go +++ b/pkg/prompt/pwd.go @@ -30,7 +30,7 @@ type Directory struct { DisplayPath string InBuildTree bool InRepoTree bool - RepoRootPath string + Repo *gitRepo NearestAccessiblePath string } @@ -78,7 +78,9 @@ func NewDirectory(path string) (dir Directory) { dir.stripHomeDirFromDisplay() //check if we are inside a Git repository - dir.RepoRootPath = findRepoRootPath(dir.Path) + var err error + dir.Repo, err = findRepo(dir.Path) + handleError(err) } return @@ -124,8 +126,8 @@ func getDirectoryField(dir Directory) string { txt := withColor("1;36", dir.DisplayPath) if dir.NearestAccessiblePath == "" { //cwd accessible -> highlight path elements inside the repo (if any) - if dir.RepoRootPath != "" && dir.RepoRootPath != dir.Path { - rel, _ := filepath.Rel(dir.RepoRootPath, dir.Path) + if dir.Repo != nil && dir.Repo.RootPath != dir.Path { + rel, _ := filepath.Rel(dir.Repo.RootPath, dir.Path) if strings.HasSuffix(dir.DisplayPath, rel) { base := strings.TrimSuffix(dir.DisplayPath, rel) txt = withColor("0;36", base) + withColor("1;36", rel) |
