Skip to content

Commit

Permalink
Merge pull request #2626 from aftix/push-pzmoxmuuokqs
Browse files Browse the repository at this point in the history
jj_completer: updated for v0.24.0
  • Loading branch information
rsteube authored Dec 7, 2024
2 parents d8647f0 + 15cc98e commit fff0f7d
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 97 deletions.
37 changes: 37 additions & 0 deletions completers/jj_completer/cmd/absorb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/jj"
"github.com/spf13/cobra"
)

var absorbCmd = &cobra.Command{
Use: "absorb [OPTIONS] [PATHS]...",
Short: "Move changes from a revision into the stack of mutable revisions",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(absorbCmd).Standalone()

absorbCmd.Flags().StringP("from", "f", "@", "Source revision to absorb from")
absorbCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
absorbCmd.Flags().StringP("into", "t", "mutable()", "Destination revisions to absorb into")
absorbCmd.Flags().String("to", "mutable()", "Alias for --into")
rootCmd.AddCommand(absorbCmd)

absorbCmd.MarkFlagsMutuallyExclusive("into", "to")

carapace.Gen(absorbCmd).FlagCompletion(carapace.ActionMap{
"from": jj.ActionRevs(jj.RevOption{}.Default()),
"into": jj.ActionRevs(jj.RevOption{}.Default()),
"to": jj.ActionRevs(jj.RevOption{}.Default()),
})

carapace.Gen(absorbCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(carapace.Context) carapace.Action {
return jj.ActionRevFiles(absorbCmd.Flag("from").Value.String())
}),
)
}
26 changes: 0 additions & 26 deletions completers/jj_completer/cmd/checkout.go

This file was deleted.

4 changes: 2 additions & 2 deletions completers/jj_completer/cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func init() {

diffCmd.Flags().Int("context", 3, "Number of lines of context to show")
diffCmd.Flags().Bool("color-words", false, "Show a word-level diff with changes indicated only by color")
diffCmd.Flags().String("from", "", "Show changes from this revision")
diffCmd.Flags().StringP("from", "-f", "", "Show changes from this revision")
diffCmd.Flags().Bool("git", false, "Show a Git-format diff")
diffCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
diffCmd.Flags().BoolP("ignore-all-space", "w", false, "Ignore whitespace when comparing lines")
Expand All @@ -27,7 +27,7 @@ func init() {
diffCmd.Flags().StringP("revision", "r", "", "Show changes in this revision, compared to its parent(s)")
diffCmd.Flags().Bool("stat", false, "Show a histogram of the changes")
diffCmd.Flags().BoolP("summary", "s", false, "For each path, show only whether it was modified, added, or removed")
diffCmd.Flags().String("to", "", "Show changes to this revision")
diffCmd.Flags().StringP("to", "t", "", "Show changes to this revision")
diffCmd.Flags().String("tool", "", "Generate diff by external command")
diffCmd.Flags().Bool("types", false, "For each path, show only its type before and after")
rootCmd.AddCommand(diffCmd)
Expand Down
4 changes: 2 additions & 2 deletions completers/jj_completer/cmd/diffedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ var diffeditCmd = &cobra.Command{
func init() {
carapace.Gen(diffeditCmd).Standalone()

diffeditCmd.Flags().String("from", "@", "Show changes from this revision. Defaults to @ if --to is specified")
diffeditCmd.Flags().StringP("from", "f", "@", "Show changes from this revision. Defaults to @ if --to is specified")
diffeditCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
diffeditCmd.Flags().Bool("restore-descendants", false, "Preserve the content (not the diff) when rebasing descendants")
diffeditCmd.Flags().StringP("revision", "r", "@", "The revision to touch up. Defaults to @ if neither --to nor --from are specified")
diffeditCmd.Flags().String("to", "@", "Edit changes in this revision. Defaults to @ if --from is specified")
diffeditCmd.Flags().StringP("to", "t", "@", "Edit changes in this revision. Defaults to @ if --from is specified")
rootCmd.AddCommand(diffeditCmd)

carapace.Gen(diffeditCmd).FlagCompletion(carapace.ActionMap{
Expand Down
19 changes: 19 additions & 0 deletions completers/jj_completer/cmd/duplicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,28 @@ var duplicateCmd = &cobra.Command{
func init() {
carapace.Gen(duplicateCmd).Standalone()

duplicateCmd.Flags().StringArray("after", []string{}, "Alias for --insert-after")
duplicateCmd.Flags().StringArray("before", []string{}, "Alias for --insert-before")
duplicateCmd.Flags().StringArrayP("destination", "d", []string{"@"}, "The revision(s) to duplicate onto (can be repeated to create a merge commit)")
duplicateCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
duplicateCmd.Flags().StringArrayP("insert-after", "A", []string{}, "The revision(s) to insert after (can be repeated to create a merge commit)")
duplicateCmd.Flags().StringArrayP("insert-before", "B", []string{}, "The revision(s) to insert before (can be repeated to create a merge commit)")
rootCmd.AddCommand(duplicateCmd)

duplicateCmd.MarkFlagsMutuallyExclusive(
"after",
"before",
"destination",
"insert-after",
"insert-before",
)

carapace.Gen(duplicateCmd).FlagCompletion(carapace.ActionMap{
"destination": jj.ActionRevs(jj.RevOption{}.Default()),
"insert-after": jj.ActionRevs(jj.RevOption{}.Default()),
"insert-before": jj.ActionRevs(jj.RevOption{}.Default()),
})

carapace.Gen(duplicateCmd).PositionalAnyCompletion(
jj.ActionRevs(jj.RevOption{}.Default()).FilterArgs(),
)
Expand Down
2 changes: 2 additions & 0 deletions completers/jj_completer/cmd/git_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func init() {

git_pushCmd.Flags().Bool("all", false, "Push all bookmarks (including deleted bookmarks)")
git_pushCmd.Flags().Bool("allow-empty-description", false, "Allow commits with empty description messages to be pushed")
git_pushCmd.Flags().BoolP("allow-new", "N", false, "Allow pushing new bookmarks")
git_pushCmd.Flags().Bool("allow-private", false, "Allow pushing commits that are private")
git_pushCmd.Flags().StringSliceP("bookmark", "b", []string{}, "Push only this bookmark (can be repeated)")
git_pushCmd.Flags().StringSliceP("change", "c", []string{}, "Push this commit by creating a bookmark based on its change ID (can be repeated)")
git_pushCmd.Flags().Bool("deleted", false, "Push all deleted bookmarks")
Expand Down
4 changes: 2 additions & 2 deletions completers/jj_completer/cmd/interdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func init() {

interdiffCmd.Flags().Int("context", 3, "Number of lines of context to show")
interdiffCmd.Flags().Bool("color-words", false, "Show a word-level diff with changes indicated only by color")
interdiffCmd.Flags().String("from", "@", "Show changes from this revision")
interdiffCmd.Flags().StringP("from", "f", "@", "Show changes from this revision")
interdiffCmd.Flags().Bool("git", false, "Show a Git-format diff")
interdiffCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
interdiffCmd.Flags().Bool("stat", false, "Show a histogram of the changes")
interdiffCmd.Flags().BoolP("summary", "s", false, "For each path, show only whether it was modified, added, or removed")
interdiffCmd.Flags().String("to", "@", "Show changes to this revision")
interdiffCmd.Flags().StringP("to", "t", "@", "Show changes to this revision")
interdiffCmd.Flags().String("tool", "", "Generate diff by external command")
interdiffCmd.Flags().Bool("types", false, "For each path, show only its type before and after")
rootCmd.AddCommand(interdiffCmd)
Expand Down
27 changes: 0 additions & 27 deletions completers/jj_completer/cmd/merge.go

This file was deleted.

34 changes: 0 additions & 34 deletions completers/jj_completer/cmd/move.go

This file was deleted.

4 changes: 2 additions & 2 deletions completers/jj_completer/cmd/operation_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ func init() {
carapace.Gen(operation_diffCmd).Standalone()

// Options
operation_diffCmd.Flags().String("from", "", "Show repository changes from this operation")
operation_diffCmd.Flags().StringP("from", "f", "", "Show repository changes from this operation")
operation_diffCmd.Flags().Bool("no-graph", false, "Don't show the graph, show a flat list of operations")
operation_diffCmd.Flags().String("operation", "", "Show repository changes in this operation, compared to its parent")
operation_diffCmd.Flags().String("to", "", "Show repository changes to this operation")
operation_diffCmd.Flags().StringP("to", "t", "", "Show repository changes to this operation")

// Diff formatting options
operation_diffCmd.Flags().Int("context", 3, "Number of lines of context to show")
Expand Down
4 changes: 2 additions & 2 deletions completers/jj_completer/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func init() {
carapace.Gen(restoreCmd).Standalone()

restoreCmd.Flags().StringP("changes-in", "c", "", "Undo the changes in a revision as compared to the merge of its parents")
restoreCmd.Flags().String("from", "@", "Revision to restore from (source)")
restoreCmd.Flags().StringP("from", "f", "@", "Revision to restore from (source)")
restoreCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
restoreCmd.Flags().Bool("restore-descendants", false, "Preserve the content (not the diff) when rebasing descendants")
restoreCmd.Flags().String("to", "@", "Revision to restore into (destination)")
restoreCmd.Flags().StringP("to", "t", "@", "Revision to restore into (destination)")
rootCmd.AddCommand(restoreCmd)

carapace.Gen(restoreCmd).FlagCompletion(carapace.ActionMap{
Expand Down
31 changes: 31 additions & 0 deletions completers/jj_completer/cmd/util_exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

var util_execCmd = &cobra.Command{
Use: "exec",
Short: "Execute an external command via jj",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(util_execCmd).Standalone()

util_execCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
utilCmd.AddCommand(util_execCmd)

carapace.Gen(util_execCmd).PositionalCompletion(
carapace.Batch(
carapace.ActionExecutables(),
carapace.ActionFiles(),
).ToA(),
)

carapace.Gen(util_execCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin(),
)
}
1 change: 1 addition & 0 deletions pkg/actions/tools/jj/rev.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ func ActionRevSetFunctions() carapace.Action {
"untracked_remote_bookmarks", "All targets of untracked remote bookmarks",
"coalesce", "Get first non-none revset from a list of revsets",
"at_operation", "Query revisions based on historical state",
"fork_point", "Obtain the fork point of multiple commits",
).Tag("revset functions")
}

0 comments on commit fff0f7d

Please sign in to comment.