Skip to content

Commit

Permalink
Merge pull request #1947 from rsteube/git-replace
Browse files Browse the repository at this point in the history
git: replace
  • Loading branch information
rsteube authored Oct 31, 2023
2 parents 458b796 + be6aa80 commit 2eddafe
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
44 changes: 44 additions & 0 deletions completers/git_completer/cmd/replace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var replaceCmd = &cobra.Command{
Use: "replace",
Short: "Create, list, delete refs to replace objects",
Run: func(cmd *cobra.Command, args []string) {},
GroupID: groups[group_manipulator].ID,
}

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

replaceCmd.Flags().Bool("convert-graft-file", false, "Creates graft commits for all entries in $GIT_DIR/info/grafts and deletes that file upon success")
replaceCmd.Flags().BoolP("delete", "d", false, "Delete existing replace refs for the given objects")
replaceCmd.Flags().String("edit", "", "Edit an object’s content interactively")
replaceCmd.Flags().BoolP("force", "f", false, "If an existing replace ref for the same object exists, it will be overwritten")
replaceCmd.Flags().String("format", "", "When listing, use the specified <format>")
replaceCmd.Flags().String("graft", "", "Create a graft commit")
replaceCmd.Flags().StringP("list", "l", "", "List replace refs for objects that match the given pattern")
replaceCmd.Flags().Bool("raw", false, "When editing, provide the raw object contents rather than pretty-printed ones")
rootCmd.AddCommand(replaceCmd)

replaceCmd.MarkFlagsMutuallyExclusive(
"convert-graft-file",
"delete",
"edit",
"graft",
)

carapace.Gen(replaceCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValuesDescribed(
"short", "<replaced sha1>",
"medium", "<replaced sha1> → <replacement sha1>",
"long", "<replaced sha1> (<replaced type>) → <replacement sha1> (<replacement type>)",
),
})

// TODO positional completion
}
26 changes: 0 additions & 26 deletions completers/git_completer/cmd/replace_generated.go

This file was deleted.

0 comments on commit 2eddafe

Please sign in to comment.