Skip to content

Commit

Permalink
git: ActionRefs - use ActionHeadCommits
Browse files Browse the repository at this point in the history
revert to using the action for correct behaviour outside git repo
  • Loading branch information
rsteube committed May 6, 2024
1 parent db6ff6b commit 99614f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/actions/tools/git/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ func ActionHeadCommits(limit int) carapace.Action {

vals := make([]string, 0)
for index, line := range lines[:len(lines)-1] {
vals = append(vals, "HEAD~"+fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(limit-1)))+"d", index), strings.TrimSpace(line[10:]))
switch index {
case 0:
vals = append(vals, "HEAD~", strings.TrimSpace(line[10:]))
default:
vals = append(vals, "HEAD~"+fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(limit-1)))+"d", index), strings.TrimSpace(line[10:]))
}
}
return carapace.ActionValuesDescribed(vals...).Style(styles.Git.HeadCommit)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/actions/tools/git/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ActionRefs(refOption RefOption) carapace.Action {
}

if refOption.HeadCommits {
batch = append(batch, carapace.ActionValues("HEAD~").NoSpace('~'))
batch = append(batch, ActionHeadCommits(1).NoSpace('~'))
}

if refOption.Tags {
Expand Down

0 comments on commit 99614f3

Please sign in to comment.