Skip to content

Commit d59f770

Browse files
authored
Merge pull request #3225 from carapace-sh/jj-changeid
jj: complete change ids
2 parents cfcfdda + 59bef6b commit d59f770

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

docs/src/choices.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Currently available bridges:
3434
- [complete](https://github.com/posener/complete)
3535
- [fish](https://fishshell.com/)
3636
- [inshellisense](https://github.com/microsoft/inshellisense)
37+
- [jj](https://www.jj-vcs.dev)
3738
- [kingpin](https://github.com/alecthomas/kingpin)
3839
- [kitten](https://github.com/kovidgoyal/kitty)
3940
- [powershell](https://microsoft.com/powershell)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/carapace-sh/carapace v1.11.0
7-
github.com/carapace-sh/carapace-bridge v1.5.0
7+
github.com/carapace-sh/carapace-bridge v1.5.1
88
github.com/carapace-sh/carapace-selfupdate v0.0.10
99
github.com/carapace-sh/carapace-shlex v1.1.1
1010
github.com/carapace-sh/carapace-spec v1.5.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/carapace-sh/carapace v1.11.0 h1:dTUFXvIrUTLd9BGLsfDt4wCgEyPl8bJeZOFDmN7fIfo=
22
github.com/carapace-sh/carapace v1.11.0/go.mod h1:NVkuv1s8wyFvu7d98rdgYwqGKMB6GO1MEUZp5RcWri8=
3-
github.com/carapace-sh/carapace-bridge v1.5.0 h1:7TaRw1o59QrKDO+7uLxupS8/IOUTOllPLicY8oe08FE=
4-
github.com/carapace-sh/carapace-bridge v1.5.0/go.mod h1:6C3kzrDWOmQM8FlK3rmTSWFi2I4M8jPCjzWJZWzBHD0=
3+
github.com/carapace-sh/carapace-bridge v1.5.1 h1:kQ6KrahugCxSuTm+ej8pUFtL6bFSTBy70n+awaZVa9w=
4+
github.com/carapace-sh/carapace-bridge v1.5.1/go.mod h1:6C3kzrDWOmQM8FlK3rmTSWFi2I4M8jPCjzWJZWzBHD0=
55
github.com/carapace-sh/carapace-pflag v1.1.0 h1:uB33wch8ADjP878NadQnbZ5vyROcj/Ac+wUQKMcIrQM=
66
github.com/carapace-sh/carapace-pflag v1.1.0/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
77
github.com/carapace-sh/carapace-selfupdate v0.0.10 h1:ZvutqGwVvSj6TmI/tLcort63JD6PaOG0ia6squwbTuo=

pkg/actions/tools/jj/change.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package jj
2+
3+
import (
4+
"strings"
5+
6+
"github.com/carapace-sh/carapace"
7+
)
8+
9+
// ActionChangeIds completes change ids
10+
//
11+
// t (message)
12+
// x (another message)
13+
func ActionChangeIds() carapace.Action {
14+
return actionExecJJ("log", "--no-graph", "--template", `change_id.shortest() ++ "\n" ++ description.first_line() ++ "\n"`)(func(output []byte) carapace.Action {
15+
lines := strings.Split(string(output), "\n")
16+
return carapace.ActionValuesDescribed(lines[:len(lines)-1]...)
17+
}).Tag("change ids")
18+
}

pkg/actions/tools/jj/commit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func ActionPrevCommits(limit int) carapace.Action {
4343
}).Tag("previous commits")
4444
}
4545

46+
// ActionNextCommits completes next commits
4647
func ActionNextCommits(limit int) carapace.Action {
4748
return actionExecJJ("log", "--no-graph", "--template", `commit_id.short() ++ "\t" ++ description.first_line() ++ "\n"`, "--revisions", "@-::", "--limit", strconv.Itoa(limit))(func(output []byte) carapace.Action {
4849
lines := strings.Split(string(output), "\n")

pkg/actions/tools/jj/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
"github.com/pelletier/go-toml"
1010
)
1111

12+
// ActionConfigs completes configs
13+
//
14+
// ui.color (never)
15+
// ui.editor (hx)
1216
func ActionConfigs(includeDefaults bool) carapace.Action {
1317
if !includeDefaults {
1418
return actionConfigs(false)

pkg/actions/tools/jj/rev.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type RevOption struct {
1212
Commits int
1313
HeadCommits int
1414
Tags bool
15+
ChangeIds bool
1516
}
1617

1718
func (o RevOption) Default() RevOption {
@@ -20,6 +21,7 @@ func (o RevOption) Default() RevOption {
2021
o.Commits = 100
2122
o.HeadCommits = 20
2223
o.Tags = true
24+
o.ChangeIds = true
2325
return o
2426

2527
}
@@ -49,6 +51,10 @@ func ActionRevs(revOption RevOption) carapace.Action {
4951
batch = append(batch, ActionTags())
5052
}
5153

54+
if revOption.ChangeIds {
55+
batch = append(batch, ActionChangeIds())
56+
}
57+
5258
return batch.ToA()
5359
})
5460
}

0 commit comments

Comments
 (0)