Detailed changes
@@ -53,9 +53,10 @@ func runAddBug(cmd *cobra.Command, args []string) error {
}
var addCmd = &cobra.Command{
- Use: "add",
- Short: "Create a new bug",
- RunE: runAddBug,
+ Use: "add",
+ Short: "Create a new bug",
+ PreRunE: loadRepo,
+ RunE: runAddBug,
}
func init() {
@@ -28,10 +28,11 @@ func runBridge(cmd *cobra.Command, args []string) error {
}
var bridgeCmd = &cobra.Command{
- Use: "bridge",
- Short: "Configure and use bridges to other bug trackers",
- RunE: runBridge,
- Args: cobra.NoArgs,
+ Use: "bridge",
+ Short: "Configure and use bridges to other bug trackers",
+ PreRunE: loadRepo,
+ RunE: runBridge,
+ Args: cobra.NoArgs,
}
func init() {
@@ -88,9 +88,10 @@ func promptName() (string, error) {
}
var bridgeConfigureCmd = &cobra.Command{
- Use: "configure",
- Short: "Configure a new bridge",
- RunE: runBridgeConfigure,
+ Use: "configure",
+ Short: "Configure a new bridge",
+ PreRunE: loadRepo,
+ RunE: runBridgeConfigure,
}
func init() {
@@ -35,9 +35,10 @@ func runBridgePull(cmd *cobra.Command, args []string) error {
}
var bridgePullCmd = &cobra.Command{
- Use: "pull [<name>]",
- Short: "Pull updates",
- RunE: runBridgePull,
+ Use: "pull [<name>]",
+ Short: "Pull updates",
+ PreRunE: loadRepo,
+ RunE: runBridgePull,
}
func init() {
@@ -22,10 +22,11 @@ func runBridgeRm(cmd *cobra.Command, args []string) error {
}
var bridgeRmCmd = &cobra.Command{
- Use: "rm name <name>",
- Short: "Delete a configured bridge",
- RunE: runBridgeRm,
- Args: cobra.ExactArgs(1),
+ Use: "rm name <name>",
+ Short: "Delete a configured bridge",
+ PreRunE: loadRepo,
+ RunE: runBridgeRm,
+ Args: cobra.ExactArgs(1),
}
func init() {
@@ -43,9 +43,10 @@ func commentsTextOutput(comments []bug.Comment) {
}
var commentCmd = &cobra.Command{
- Use: "comment [<id>]",
- Short: "Display or add comments",
- RunE: runComment,
+ Use: "comment [<id>]",
+ Short: "Display or add comments",
+ PreRunE: loadRepo,
+ RunE: runComment,
}
func init() {
@@ -53,9 +53,10 @@ func runCommentAdd(cmd *cobra.Command, args []string) error {
}
var commentAddCmd = &cobra.Command{
- Use: "add [<id>]",
- Short: "Add a new comment",
- RunE: runCommentAdd,
+ Use: "add [<id>]",
+ Short: "Add a new comment",
+ PreRunE: loadRepo,
+ RunE: runCommentAdd,
}
func init() {
@@ -29,7 +29,8 @@ git bug comment
git bug status
git bug deselect
`,
- RunE: runDeselect,
+ PreRunE: loadRepo,
+ RunE: runDeselect,
}
func init() {
@@ -30,9 +30,10 @@ func runLabel(cmd *cobra.Command, args []string) error {
}
var labelCmd = &cobra.Command{
- Use: "label [<id>]",
- Short: "Display, add or remove labels",
- RunE: runLabel,
+ Use: "label [<id>]",
+ Short: "Display, add or remove labels",
+ PreRunE: loadRepo,
+ RunE: runLabel,
}
func init() {
@@ -34,9 +34,10 @@ func runLabelAdd(cmd *cobra.Command, args []string) error {
}
var labelAddCmd = &cobra.Command{
- Use: "add [<id>] <label>[...]",
- Short: "Add a label",
- RunE: runLabelAdd,
+ Use: "add [<id>] <label>[...]",
+ Short: "Add a label",
+ PreRunE: loadRepo,
+ RunE: runLabelAdd,
}
func init() {
@@ -34,9 +34,10 @@ func runLabelRm(cmd *cobra.Command, args []string) error {
}
var labelRmCmd = &cobra.Command{
- Use: "rm [<id>] <label>[...]",
- Short: "Remove a label",
- RunE: runLabelRm,
+ Use: "rm [<id>] <label>[...]",
+ Short: "Remove a label",
+ PreRunE: loadRepo,
+ RunE: runLabelRm,
}
func init() {
@@ -29,7 +29,8 @@ var lsLabelCmd = &cobra.Command{
Long: `List valid labels.
Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
- RunE: runLsLabel,
+ PreRunE: loadRepo,
+ RunE: runLsLabel,
}
func init() {
@@ -139,7 +139,8 @@ git bug ls status:open sort:edit-desc
List closed bugs sorted by creation with flags:
git bug ls --status closed --by creation
`,
- RunE: runLsBug,
+ PreRunE: loadRepo,
+ RunE: runLsBug,
}
func init() {
@@ -51,9 +51,10 @@ func runPull(cmd *cobra.Command, args []string) error {
// showCmd defines the "push" subcommand.
var pullCmd = &cobra.Command{
- Use: "pull [<remote>]",
- Short: "Pull bugs update from a git remote",
- RunE: runPull,
+ Use: "pull [<remote>]",
+ Short: "Pull bugs update from a git remote",
+ PreRunE: loadRepo,
+ RunE: runPull,
}
func init() {
@@ -36,9 +36,10 @@ func runPush(cmd *cobra.Command, args []string) error {
// showCmd defines the "push" subcommand.
var pushCmd = &cobra.Command{
- Use: "push [<remote>]",
- Short: "Push bugs update to a git remote",
- RunE: runPush,
+ Use: "push [<remote>]",
+ Short: "Push bugs update to a git remote",
+ PreRunE: loadRepo,
+ RunE: runPush,
}
func init() {
@@ -38,10 +38,6 @@ the same git remote your are already using to collaborate with other peoples.
}
},
- // Load the repo before any command execution
- // Note, this concern only commands that actually have a Run function
- PersistentPreRunE: loadRepo,
-
DisableAutoGenTag: true,
// Custom bash code to connect the git completion for "git bug" to the
@@ -44,7 +44,8 @@ var selectCmd = &cobra.Command{
git bug comment
git bug status
`,
- RunE: runSelect,
+ PreRunE: loadRepo,
+ RunE: runSelect,
}
func init() {
@@ -73,9 +73,10 @@ func runShowBug(cmd *cobra.Command, args []string) error {
}
var showCmd = &cobra.Command{
- Use: "show [<id>]",
- Short: "Display the details of a bug",
- RunE: runShowBug,
+ Use: "show [<id>]",
+ Short: "Display the details of a bug",
+ PreRunE: loadRepo,
+ RunE: runShowBug,
}
func init() {
@@ -28,9 +28,10 @@ func runStatus(cmd *cobra.Command, args []string) error {
}
var statusCmd = &cobra.Command{
- Use: "status [<id>]",
- Short: "Display or change a bug status",
- RunE: runStatus,
+ Use: "status [<id>]",
+ Short: "Display or change a bug status",
+ PreRunE: loadRepo,
+ RunE: runStatus,
}
func init() {
@@ -27,9 +27,10 @@ func runStatusClose(cmd *cobra.Command, args []string) error {
}
var closeCmd = &cobra.Command{
- Use: "close [<id>]",
- Short: "Mark a bug as closed",
- RunE: runStatusClose,
+ Use: "close [<id>]",
+ Short: "Mark a bug as closed",
+ PreRunE: loadRepo,
+ RunE: runStatusClose,
}
func init() {
@@ -27,9 +27,10 @@ func runStatusOpen(cmd *cobra.Command, args []string) error {
}
var openCmd = &cobra.Command{
- Use: "open [<id>]",
- Short: "Mark a bug as open",
- RunE: runStatusOpen,
+ Use: "open [<id>]",
+ Short: "Mark a bug as open",
+ PreRunE: loadRepo,
+ RunE: runStatusOpen,
}
func init() {
@@ -17,9 +17,10 @@ func runTermUI(cmd *cobra.Command, args []string) error {
}
var termUICmd = &cobra.Command{
- Use: "termui",
- Short: "Launch the terminal UI",
- RunE: runTermUI,
+ Use: "termui",
+ Short: "Launch the terminal UI",
+ PreRunE: loadRepo,
+ RunE: runTermUI,
}
func init() {
@@ -28,9 +28,10 @@ func runTitle(cmd *cobra.Command, args []string) error {
}
var titleCmd = &cobra.Command{
- Use: "title [<id>]",
- Short: "Display or change a title",
- RunE: runTitle,
+ Use: "title [<id>]",
+ Short: "Display or change a title",
+ PreRunE: loadRepo,
+ RunE: runTitle,
}
func init() {
@@ -51,9 +51,10 @@ func runTitleEdit(cmd *cobra.Command, args []string) error {
}
var titleEditCmd = &cobra.Command{
- Use: "edit [<id>]",
- Short: "Edit a title",
- RunE: runTitleEdit,
+ Use: "edit [<id>]",
+ Short: "Edit a title",
+ PreRunE: loadRepo,
+ RunE: runTitleEdit,
}
func init() {
@@ -223,9 +223,10 @@ func (gufh *gitUploadFileHandler) ServeHTTP(rw http.ResponseWriter, r *http.Requ
}
var webUICmd = &cobra.Command{
- Use: "webui",
- Short: "Launch the web UI",
- RunE: runWebUI,
+ Use: "webui",
+ Short: "Launch the web UI",
+ PreRunE: loadRepo,
+ RunE: runWebUI,
}
func init() {