-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1593 from rsteube/git-notes
git: notes
- Loading branch information
Showing
15 changed files
with
306 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_addCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Add notes for a given object", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_addCmd).Standalone() | ||
|
||
notes_addCmd.Flags().Bool("allow-empty", false, "Allow an empty note object to be stored") | ||
notes_addCmd.Flags().StringP("file", "F", "", "Take the note message from the given file") | ||
notes_addCmd.Flags().StringP("message", "m", "", "Use the given note message") | ||
notes_addCmd.Flags().StringP("reedit-message", "c", "", "Like -C, but with -c the editor is invoked") | ||
notes_addCmd.Flags().StringP("reuse-message", "C", "", "Take the given blob object as the note message") | ||
notesCmd.AddCommand(notes_addCmd) | ||
|
||
carapace.Gen(notes_addCmd).FlagCompletion(carapace.ActionMap{ | ||
"file": carapace.ActionFiles(), | ||
"reedit-message": git.ActionRefs(git.RefOption{}.Default()), | ||
"reuse-message": git.ActionRefs(git.RefOption{}.Default()), | ||
}) | ||
|
||
carapace.Gen(notes_addCmd).PositionalCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_appendCmd = &cobra.Command{ | ||
Use: "append", | ||
Short: "Append to the notes of an existing object", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_appendCmd).Standalone() | ||
|
||
notes_appendCmd.Flags().Bool("allow-empty", false, "Allow an empty note object to be stored") | ||
notes_appendCmd.Flags().StringP("file", "F", "", "Take the note message from the given file") | ||
notes_appendCmd.Flags().StringP("message", "m", "", "Use the given note message") | ||
notes_appendCmd.Flags().StringP("reedit-message", "c", "", "Like -C, but with -c the editor is invoked") | ||
notes_appendCmd.Flags().StringP("reuse-message", "C", "", "Take the given blob object as the note message") | ||
notesCmd.AddCommand(notes_appendCmd) | ||
|
||
carapace.Gen(notes_appendCmd).FlagCompletion(carapace.ActionMap{ | ||
"file": carapace.ActionFiles(), | ||
"reedit-message": git.ActionRefs(git.RefOption{}.Default()), | ||
"reuse-message": git.ActionRefs(git.RefOption{}.Default()), | ||
}) | ||
|
||
carapace.Gen(notes_appendCmd).PositionalCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_copyCmd = &cobra.Command{ | ||
Use: "copy", | ||
Short: "Copy the notes for the first object onto the second object", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_copyCmd).Standalone() | ||
|
||
notes_copyCmd.Flags().BoolP("force", "f", false, "Overwrite existing notes") | ||
notes_copyCmd.Flags().Bool("stdin", false, "Also read the object names to remove notes from the standard input") | ||
notesCmd.AddCommand(notes_copyCmd) | ||
|
||
carapace.Gen(notes_copyCmd).PositionalCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_editCmd = &cobra.Command{ | ||
Use: "edit", | ||
Short: "Edit the notes for a given object", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_editCmd).Standalone() | ||
|
||
notes_editCmd.Flags().Bool("allow-empty", false, "Allow an empty note object to be stored") | ||
notesCmd.AddCommand(notes_editCmd) | ||
|
||
carapace.Gen(notes_editCmd).PositionalCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_getRefCmd = &cobra.Command{ | ||
Use: "get-ref", | ||
Short: "Print the current notes ref", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_getRefCmd).Standalone() | ||
|
||
notesCmd.AddCommand(notes_getRefCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_listCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List the notes object for a given object", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_listCmd).Standalone() | ||
|
||
notesCmd.AddCommand(notes_listCmd) | ||
|
||
carapace.Gen(notes_listCmd).PositionalCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_mergeCmd = &cobra.Command{ | ||
Use: "merge", | ||
Short: "Merge the given notes ref into the current notes ref", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_mergeCmd).Standalone() | ||
|
||
notes_mergeCmd.Flags().Bool("abort", false, "Abort/reset an in-progress git notes merge") | ||
notes_mergeCmd.Flags().Bool("commit", false, "Finalize an in-progress git notes merge") | ||
notes_mergeCmd.Flags().BoolP("quiet", "q", false, "When merging notes, operate quietly") | ||
notes_mergeCmd.Flags().StringP("strategy", "s", "", "Resolve notes conflicts using the given strategy") | ||
notes_mergeCmd.Flags().BoolP("verbose", "v", false, "When merging notes, be more verbose") | ||
notesCmd.AddCommand(notes_mergeCmd) | ||
|
||
notes_mergeCmd.MarkFlagsMutuallyExclusive("abort", "commit", "strategy") | ||
|
||
carapace.Gen(notes_mergeCmd).FlagCompletion(carapace.ActionMap{ | ||
"strategy": git.ActionNotesMergeStrategies(), | ||
}) | ||
|
||
carapace.Gen(notes_mergeCmd).PositionalCompletion( | ||
git.ActionNotes(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_pruneCmd = &cobra.Command{ | ||
Use: "prune", | ||
Short: "Remove all notes for non-existing/unreachable objects", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_pruneCmd).Standalone() | ||
|
||
notes_pruneCmd.Flags().BoolP("dry-run", "n", false, "Do not remove anything, just report") | ||
notes_pruneCmd.Flags().BoolP("verbose", "v", false, "When merging notes, be more verbose") | ||
notesCmd.AddCommand(notes_pruneCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_removeCmd = &cobra.Command{ | ||
Use: "remove", | ||
Short: "Remove the notes for given objects", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_removeCmd).Standalone() | ||
|
||
notes_removeCmd.Flags().Bool("ignore-missing", false, "Do not consider it an error to request removing non existing notes") | ||
notes_removeCmd.Flags().Bool("stdin", false, "Also read the object names to remove notes from the standard input") | ||
notesCmd.AddCommand(notes_removeCmd) | ||
|
||
carapace.Gen(notes_removeCmd).PositionalAnyCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var notes_showCmd = &cobra.Command{ | ||
Use: "show", | ||
Short: "Show the notes for a given object", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(notes_showCmd).Standalone() | ||
|
||
notesCmd.AddCommand(notes_showCmd) | ||
|
||
carapace.Gen(notes_showCmd).PositionalCompletion( | ||
git.ActionRefs(git.RefOption{}.Default()), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package git | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/styles" | ||
) | ||
|
||
// ActionNotes completes notes | ||
|
||
func ActionNotes() carapace.Action { | ||
return carapace.ActionExecCommand("git", "log", "--pretty=format:%h\n%<(64,trunc)%s", "--show-notes")(func(output []byte) carapace.Action { | ||
lines := strings.Split(string(output), "\n") | ||
return carapace.ActionValuesDescribed(lines...).Style(styles.Git.Note) | ||
}).Tag("notes") | ||
} | ||
|
||
// ActionNotesMergeStrategies completes notes merge strategies | ||
// | ||
// ours (favor the local version) | ||
// theirs (favor the remote version) | ||
func ActionNotesMergeStrategies() carapace.Action { | ||
return carapace.ActionValuesDescribed( | ||
"manual", "check out conflicting notes in a special work tree", | ||
"ours", "favor the local version", | ||
"theirs", "favor the remote version", | ||
"union", "concatenate the local and remote versions", | ||
"cat_sort_uniq", "similar to \"union\", but also sorts removes duplicate lines", | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters