|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/carapace-sh/carapace" |
| 5 | + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/git" |
| 6 | + "github.com/spf13/cobra" |
| 7 | +) |
| 8 | + |
| 9 | +var subtree_pushCmd = &cobra.Command{ |
| 10 | + Use: "push <repository> [+][<local-commit>:]<remote-ref>", |
| 11 | + Short: "Push your subtree to different branches of the remote repository", |
| 12 | + Run: func(cmd *cobra.Command, args []string) {}, |
| 13 | +} |
| 14 | + |
| 15 | +func init() { |
| 16 | + carapace.Gen(subtree_pushCmd).Standalone() |
| 17 | + |
| 18 | + subtree_pushCmd.Flags().String("annotate", "", "add <annotation> as a prefix to each commit message") |
| 19 | + subtree_pushCmd.Flags().StringP("branch", "b", "", "create a new branch called <branch> that contains the new history") |
| 20 | + subtree_pushCmd.Flags().Bool("ignore-joins", false, "regenerate the entire history") |
| 21 | + subtree_pushCmd.Flags().StringP("message", "m", "", "Specify <message> as the commit message for the merge commit") |
| 22 | + subtree_pushCmd.Flags().String("onto", "", "specify the commit ID <onto> to build history from") |
| 23 | + subtree_pushCmd.Flags().Bool("rejoin", false, "merge the newly created synthetic history back into your main project") |
| 24 | + subtreeCmd.AddCommand(subtree_pushCmd) |
| 25 | + |
| 26 | + // TODO check and fix completion |
| 27 | + carapace.Gen(subtree_pushCmd).PositionalCompletion( |
| 28 | + git.ActionRemotes(), |
| 29 | + carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { |
| 30 | + switch len(c.Parts) { |
| 31 | + case 0: |
| 32 | + return git.ActionRefs(git.RefOption{ |
| 33 | + LocalBranches: true, |
| 34 | + HeadCommits: true, |
| 35 | + Tags: true, |
| 36 | + }).NoSpace() |
| 37 | + default: |
| 38 | + return git.ActionRemoteBranchNames(c.Args[0]) |
| 39 | + } |
| 40 | + }), |
| 41 | + ) |
| 42 | +} |
0 commit comments