aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-10-17 20:38:10 +0200
committerMichael Muré <batolettre@gmail.com>2018-10-17 20:39:35 +0200
commit7a511f9a13f3d1064fd11c9146e6b21cb961a8b2 (patch)
tree3ef98347986e32bd33efe8c5d5d66a8ba78b84af /commands
parent0e5c5a4db4461f0518dfea190b70683f7703fa09 (diff)
downloadgit-bug-7a511f9a13f3d1064fd11c9146e6b21cb961a8b2.tar.gz
commands: don't load the repo for commands that don't need it
fix #67
Diffstat (limited to 'commands')
-rw-r--r--commands/add.go7
-rw-r--r--commands/bridge.go9
-rw-r--r--commands/bridge_configure.go7
-rw-r--r--commands/bridge_pull.go7
-rw-r--r--commands/bridge_rm.go9
-rw-r--r--commands/comment.go7
-rw-r--r--commands/comment_add.go7
-rw-r--r--commands/deselect.go3
-rw-r--r--commands/label.go7
-rw-r--r--commands/label_add.go7
-rw-r--r--commands/label_rm.go7
-rw-r--r--commands/ls-labels.go3
-rw-r--r--commands/ls.go3
-rw-r--r--commands/pull.go7
-rw-r--r--commands/push.go7
-rw-r--r--commands/root.go4
-rw-r--r--commands/select.go3
-rw-r--r--commands/show.go7
-rw-r--r--commands/status.go7
-rw-r--r--commands/status_close.go7
-rw-r--r--commands/status_open.go7
-rw-r--r--commands/termui.go7
-rw-r--r--commands/title.go7
-rw-r--r--commands/title_edit.go7
-rw-r--r--commands/webui.go7
25 files changed, 90 insertions, 70 deletions
diff --git a/commands/add.go b/commands/add.go
index 944f0a99..081c99f1 100644
--- a/commands/add.go
+++ b/commands/add.go
@@ -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() {
diff --git a/commands/bridge.go b/commands/bridge.go
index 5dc4e744..4576cd0a 100644
--- a/commands/bridge.go
+++ b/commands/bridge.go
@@ -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() {
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go
index 4329b54c..ed18cae9 100644
--- a/commands/bridge_configure.go
+++ b/commands/bridge_configure.go
@@ -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() {
diff --git a/commands/bridge_pull.go b/commands/bridge_pull.go
index 521f2d9c..a90a533f 100644
--- a/commands/bridge_pull.go
+++ b/commands/bridge_pull.go
@@ -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() {
diff --git a/commands/bridge_rm.go b/commands/bridge_rm.go
index acde9da5..2ebc17a7 100644
--- a/commands/bridge_rm.go
+++ b/commands/bridge_rm.go
@@ -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() {
diff --git a/commands/comment.go b/commands/comment.go
index c05fd255..fc4b6a6b 100644
--- a/commands/comment.go
+++ b/commands/comment.go
@@ -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() {
diff --git a/commands/comment_add.go b/commands/comment_add.go
index 8736f9c2..6ee3fc15 100644
--- a/commands/comment_add.go
+++ b/commands/comment_add.go
@@ -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() {
diff --git a/commands/deselect.go b/commands/deselect.go
index f2907c70..a2e8d30d 100644
--- a/commands/deselect.go
+++ b/commands/deselect.go
@@ -29,7 +29,8 @@ git bug comment
git bug status
git bug deselect
`,
- RunE: runDeselect,
+ PreRunE: loadRepo,
+ RunE: runDeselect,
}
func init() {
diff --git a/commands/label.go b/commands/label.go
index fd958d68..0221701c 100644
--- a/commands/label.go
+++ b/commands/label.go
@@ -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() {
diff --git a/commands/label_add.go b/commands/label_add.go
index 06c4e6c5..278d6472 100644
--- a/commands/label_add.go
+++ b/commands/label_add.go
@@ -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() {
diff --git a/commands/label_rm.go b/commands/label_rm.go
index 5e9c8f24..e53ac09a 100644
--- a/commands/label_rm.go
+++ b/commands/label_rm.go
@@ -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() {
diff --git a/commands/ls-labels.go b/commands/ls-labels.go
index 49f4c7cb..9dd94f08 100644
--- a/commands/ls-labels.go
+++ b/commands/ls-labels.go
@@ -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() {
diff --git a/commands/ls.go b/commands/ls.go
index 1fababaa..1a759a26 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -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() {
diff --git a/commands/pull.go b/commands/pull.go
index 73a27d3d..27c0953b 100644
--- a/commands/pull.go
+++ b/commands/pull.go
@@ -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() {
diff --git a/commands/push.go b/commands/push.go
index 06a4044b..11282ada 100644
--- a/commands/push.go
+++ b/commands/push.go
@@ -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() {
diff --git a/commands/root.go b/commands/root.go
index d7e7216d..27268bf4 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -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
diff --git a/commands/select.go b/commands/select.go
index b917d31d..0c50d1a6 100644
--- a/commands/select.go
+++ b/commands/select.go
@@ -44,7 +44,8 @@ var selectCmd = &cobra.Command{
git bug comment
git bug status
`,
- RunE: runSelect,
+ PreRunE: loadRepo,
+ RunE: runSelect,
}
func init() {
diff --git a/commands/show.go b/commands/show.go
index c061b69b..c41af02d 100644
--- a/commands/show.go
+++ b/commands/show.go
@@ -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() {
diff --git a/commands/status.go b/commands/status.go
index a34b0918..6aed000a 100644
--- a/commands/status.go
+++ b/commands/status.go
@@ -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() {
diff --git a/commands/status_close.go b/commands/status_close.go
index fd713a39..ec4e503e 100644
--- a/commands/status_close.go
+++ b/commands/status_close.go
@@ -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() {
diff --git a/commands/status_open.go b/commands/status_open.go
index 9c6363a0..c8717cd2 100644
--- a/commands/status_open.go
+++ b/commands/status_open.go
@@ -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() {
diff --git a/commands/termui.go b/commands/termui.go
index 5d600710..8df5ba7c 100644
--- a/commands/termui.go
+++ b/commands/termui.go
@@ -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() {
diff --git a/commands/title.go b/commands/title.go
index f930ffb1..5d723755 100644
--- a/commands/title.go
+++ b/commands/title.go
@@ -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() {
diff --git a/commands/title_edit.go b/commands/title_edit.go
index 2d824383..f3b93bb1 100644
--- a/commands/title_edit.go
+++ b/commands/title_edit.go
@@ -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() {
diff --git a/commands/webui.go b/commands/webui.go
index b1bccd5c..e2a3265c 100644
--- a/commands/webui.go
+++ b/commands/webui.go
@@ -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() {