Skip to content

Commit

Permalink
Merge pull request #2040 from rsteube/git-head-tilde
Browse files Browse the repository at this point in the history
git: ActionRefs - include tilde suffix for `HEAD`
  • Loading branch information
rsteube authored Nov 27, 2023
2 parents 7268442 + 349b47d commit 4dc0c34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/actions/tools/git/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/styles"
)

func rootDir(c carapace.Context) (string, error) {
Expand Down Expand Up @@ -57,7 +58,11 @@ func ActionRefs(refOption RefOption) carapace.Action {
batch = append(batch, ActionRecentCommits(refOption.Commits))
}

if refOption.HeadCommits > 0 {
switch refOption.HeadCommits {
case 0:
case 1: // add with `~` for convenience
batch = append(batch, carapace.ActionValues("HEAD~").NoSpace('~').Style(styles.Git.HeadCommit).Tag("head commits"))
default:
batch = append(batch, ActionHeadCommits(refOption.HeadCommits))
}

Expand Down

0 comments on commit 4dc0c34

Please sign in to comment.