Skip to content

Commit

Permalink
feat: show no commits context
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Dec 31, 2020
1 parent 8c68b89 commit 11350c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/docs/segment-git.md
Expand Up @@ -12,6 +12,7 @@ Local changes can also shown by default using the following syntax for both the
- `+` added
- `~` modified
- `-` deleted
- `?` untracked

## Sample Configuration

Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions src/segment_git.go
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 11350c7

Please sign in to comment.