diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2017-08-19 21:00:34 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2017-08-19 21:00:34 +0200 |
| commit | 4599d09dc26634e4fce69fc6df40cd5c15b3d5de (patch) | |
| tree | 9ad0b91bbd1bf99c67fc643d7f34dfaf7e5dd792 /pkg/prompt/git.go | |
| parent | b017ff3fbf272808839e344210741206d94d50da (diff) | |
| download | gofu-4599d09dc26634e4fce69fc6df40cd5c15b3d5de.tar.gz | |
prompt: handle newly initialized Git repo without any commits correctly
Diffstat (limited to 'pkg/prompt/git.go')
| -rw-r--r-- | pkg/prompt/git.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/prompt/git.go b/pkg/prompt/git.go index 20f9445..054df36 100644 --- a/pkg/prompt/git.go +++ b/pkg/prompt/git.go @@ -63,8 +63,12 @@ func getRepoStatusField(repoRootPath string) string { bytes, err = ioutil.ReadFile(filepath.Join(repoRootPath, ".git", refSpec)) commitID := strings.TrimSpace(string(bytes)) if err != nil { - handleError(err) - commitID = withColor("1;41", "unknown") + if os.IsNotExist(err) { + commitID = withColor("37", "blank") + } else { + handleError(err) + commitID = withColor("1;41", "unknown") + } } return formatRepoStatusField(refSpecDisplay, commitID) |
