feat: show no commits context

This commit is contained in:
Jan De Dobbeleer 2020-12-31 20:08:16 +01:00 committed by Jan De Dobbeleer
parent 8c68b89790
commit 11350c7347
2 changed files with 7 additions and 0 deletions

View file

@ -12,6 +12,7 @@ Local changes can also shown by default using the following syntax for both the
- `+` added
- `~` modified
- `-` deleted
- `?` untracked
## Sample Configuration
@ -56,6 +57,7 @@ Local changes can also shown by default using the following syntax for both the
- rebase_icon: `string` - icon/text to display before the context when in a rebase - defaults to `\uE728 `
- cherry_pick_icon: `string` - icon/text to display before the context when doing a cherry-pick - defaults to `\uE29B `
- merge_icon: `string` icon/text to display before the merge context - defaults to `\uE727 `
- no_commits_icon: `string` icon/text to display when there are no commits in the repo - defaults to `\uF594 `
### Upstream context

View file

@ -78,6 +78,8 @@ const (
CherryPickIcon Property = "cherry_pick_icon"
// CommitIcon shows before the detached context
CommitIcon Property = "commit_icon"
// NoCommitsIcon shows when there are no commits in the repo yet
NoCommitsIcon Property = "no_commits_icon"
// TagIcon shows before the tag context
TagIcon Property = "tag_icon"
// DisplayStashCount show stash count or not
@ -309,6 +311,9 @@ func (g *git) getPrettyHEADName() string {
}
// fallback to commit
ref = g.getGitCommandOutput("rev-parse", "--short", "HEAD")
if ref == "" {
return g.props.getString(NoCommitsIcon, "\uF594 ")
}
return fmt.Sprintf("%s%s", g.props.getString(CommitIcon, "\uF417"), ref)
}