aboutsummaryrefslogtreecommitdiffstats
path: root/commands/bug
diff options
context:
space:
mode:
Diffstat (limited to 'commands/bug')
-rw-r--r--commands/bug/bug.go21
-rw-r--r--commands/bug/bug_comment.go8
-rw-r--r--commands/bug/bug_comment_add.go3
-rw-r--r--commands/bug/bug_comment_edit.go3
-rw-r--r--commands/bug/bug_comment_test.go1
-rw-r--r--commands/bug/bug_deselect.go4
-rw-r--r--commands/bug/bug_label.go8
-rw-r--r--commands/bug/bug_label_new.go4
-rw-r--r--commands/bug/bug_label_rm.go4
-rw-r--r--commands/bug/bug_new.go3
-rw-r--r--commands/bug/bug_rm.go4
-rw-r--r--commands/bug/bug_select.go4
-rw-r--r--commands/bug/bug_show.go3
-rw-r--r--commands/bug/bug_status.go8
-rw-r--r--commands/bug/bug_status_close.go4
-rw-r--r--commands/bug/bug_status_open.go4
-rw-r--r--commands/bug/bug_title.go6
-rw-r--r--commands/bug/bug_title_edit.go3
18 files changed, 34 insertions, 61 deletions
diff --git a/commands/bug/bug.go b/commands/bug/bug.go
index a5243c1d..4c83ffa5 100644
--- a/commands/bug/bug.go
+++ b/commands/bug/bug.go
@@ -34,8 +34,7 @@ type bugOptions struct {
outputFormat string
}
-func NewBugCommand() *cobra.Command {
- env := execenv.NewEnv()
+func NewBugCommand(env *execenv.Env) *cobra.Command {
options := bugOptions{}
cmd := &cobra.Command{
@@ -107,16 +106,16 @@ git bug status:open --by creation "foo bar" baz
child.GroupID = groupID
}
- addCmdWithGroup(newBugDeselectCommand(), selectGroup)
- addCmdWithGroup(newBugSelectCommand(), selectGroup)
+ addCmdWithGroup(newBugDeselectCommand(env), selectGroup)
+ addCmdWithGroup(newBugSelectCommand(env), selectGroup)
- cmd.AddCommand(newBugCommentCommand())
- cmd.AddCommand(newBugLabelCommand())
- cmd.AddCommand(newBugNewCommand())
- cmd.AddCommand(newBugRmCommand())
- cmd.AddCommand(newBugShowCommand())
- cmd.AddCommand(newBugStatusCommand())
- cmd.AddCommand(newBugTitleCommand())
+ cmd.AddCommand(newBugCommentCommand(env))
+ cmd.AddCommand(newBugLabelCommand(env))
+ cmd.AddCommand(newBugNewCommand(env))
+ cmd.AddCommand(newBugRmCommand(env))
+ cmd.AddCommand(newBugShowCommand(env))
+ cmd.AddCommand(newBugStatusCommand(env))
+ cmd.AddCommand(newBugTitleCommand(env))
return cmd
}
diff --git a/commands/bug/bug_comment.go b/commands/bug/bug_comment.go
index 4dc8dc1f..5cb8ff17 100644
--- a/commands/bug/bug_comment.go
+++ b/commands/bug/bug_comment.go
@@ -8,9 +8,7 @@ import (
"github.com/MichaelMure/git-bug/util/colors"
)
-func newBugCommentCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugCommentCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "comment [BUG_ID]",
Short: "List a bug's comments",
@@ -21,8 +19,8 @@ func newBugCommentCommand() *cobra.Command {
ValidArgsFunction: BugCompletion(env),
}
- cmd.AddCommand(newBugCommentNewCommand())
- cmd.AddCommand(newBugCommentEditCommand())
+ cmd.AddCommand(newBugCommentNewCommand(env))
+ cmd.AddCommand(newBugCommentEditCommand(env))
return cmd
}
diff --git a/commands/bug/bug_comment_add.go b/commands/bug/bug_comment_add.go
index ff406b4f..152a1893 100644
--- a/commands/bug/bug_comment_add.go
+++ b/commands/bug/bug_comment_add.go
@@ -14,8 +14,7 @@ type bugCommentNewOptions struct {
nonInteractive bool
}
-func newBugCommentNewCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBugCommentNewCommand(env *execenv.Env) *cobra.Command {
options := bugCommentNewOptions{}
cmd := &cobra.Command{
diff --git a/commands/bug/bug_comment_edit.go b/commands/bug/bug_comment_edit.go
index ded3d82a..e6f8d667 100644
--- a/commands/bug/bug_comment_edit.go
+++ b/commands/bug/bug_comment_edit.go
@@ -13,8 +13,7 @@ type bugCommentEditOptions struct {
nonInteractive bool
}
-func newBugCommentEditCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBugCommentEditCommand(env *execenv.Env) *cobra.Command {
options := bugCommentEditOptions{}
cmd := &cobra.Command{
diff --git a/commands/bug/bug_comment_test.go b/commands/bug/bug_comment_test.go
index 5625f1be..ecc1c5f6 100644
--- a/commands/bug/bug_comment_test.go
+++ b/commands/bug/bug_comment_test.go
@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/MichaelMure/git-bug/commands/bug/testenv"
+ "github.com/MichaelMure/git-bug/commands/cmdtest"
"github.com/MichaelMure/git-bug/commands/execenv"
)
diff --git a/commands/bug/bug_deselect.go b/commands/bug/bug_deselect.go
index 090a7bf2..5e9acc60 100644
--- a/commands/bug/bug_deselect.go
+++ b/commands/bug/bug_deselect.go
@@ -8,9 +8,7 @@ import (
"github.com/MichaelMure/git-bug/entities/bug"
)
-func newBugDeselectCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugDeselectCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "deselect",
Short: "Clear the implicitly selected bug",
diff --git a/commands/bug/bug_label.go b/commands/bug/bug_label.go
index e6d0e603..554496e3 100644
--- a/commands/bug/bug_label.go
+++ b/commands/bug/bug_label.go
@@ -6,9 +6,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBugLabelCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugLabelCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "label [BUG_ID]",
Short: "Display labels of a bug",
@@ -19,8 +17,8 @@ func newBugLabelCommand() *cobra.Command {
ValidArgsFunction: BugCompletion(env),
}
- cmd.AddCommand(newBugLabelNewCommand())
- cmd.AddCommand(newBugLabelRmCommand())
+ cmd.AddCommand(newBugLabelNewCommand(env))
+ cmd.AddCommand(newBugLabelRmCommand(env))
return cmd
}
diff --git a/commands/bug/bug_label_new.go b/commands/bug/bug_label_new.go
index aa4f9463..1e1f2d4f 100644
--- a/commands/bug/bug_label_new.go
+++ b/commands/bug/bug_label_new.go
@@ -7,9 +7,7 @@ import (
"github.com/MichaelMure/git-bug/util/text"
)
-func newBugLabelNewCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugLabelNewCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "new [BUG_ID] LABEL...",
Short: "Add a label to a bug",
diff --git a/commands/bug/bug_label_rm.go b/commands/bug/bug_label_rm.go
index 18510bbd..6dda007c 100644
--- a/commands/bug/bug_label_rm.go
+++ b/commands/bug/bug_label_rm.go
@@ -7,9 +7,7 @@ import (
"github.com/MichaelMure/git-bug/util/text"
)
-func newBugLabelRmCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugLabelRmCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "rm [BUG_ID] LABEL...",
Short: "Remove a label from a bug",
diff --git a/commands/bug/bug_new.go b/commands/bug/bug_new.go
index 9ef288e9..e66967f9 100644
--- a/commands/bug/bug_new.go
+++ b/commands/bug/bug_new.go
@@ -15,8 +15,7 @@ type bugNewOptions struct {
nonInteractive bool
}
-func newBugNewCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBugNewCommand(env *execenv.Env) *cobra.Command {
options := bugNewOptions{}
cmd := &cobra.Command{
diff --git a/commands/bug/bug_rm.go b/commands/bug/bug_rm.go
index 386c57ec..b9d3d525 100644
--- a/commands/bug/bug_rm.go
+++ b/commands/bug/bug_rm.go
@@ -8,9 +8,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBugRmCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugRmCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "rm BUG_ID",
Short: "Remove an existing bug",
diff --git a/commands/bug/bug_select.go b/commands/bug/bug_select.go
index bfad899d..652c61ea 100644
--- a/commands/bug/bug_select.go
+++ b/commands/bug/bug_select.go
@@ -15,9 +15,7 @@ func ResolveSelected(repo *cache.RepoCache, args []string) (*cache.BugCache, []s
return _select.Resolve[*cache.BugCache](repo, bug.Typename, bug.Namespace, repo.Bugs(), args)
}
-func newBugSelectCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugSelectCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "select BUG_ID",
Short: "Select a bug for implicit use in future commands",
diff --git a/commands/bug/bug_show.go b/commands/bug/bug_show.go
index 9f80120c..9a03c9a3 100644
--- a/commands/bug/bug_show.go
+++ b/commands/bug/bug_show.go
@@ -19,8 +19,7 @@ type bugShowOptions struct {
format string
}
-func newBugShowCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBugShowCommand(env *execenv.Env) *cobra.Command {
options := bugShowOptions{}
cmd := &cobra.Command{
diff --git a/commands/bug/bug_status.go b/commands/bug/bug_status.go
index 807a9a60..59bef3fd 100644
--- a/commands/bug/bug_status.go
+++ b/commands/bug/bug_status.go
@@ -6,9 +6,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBugStatusCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugStatusCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "status [BUG_ID]",
Short: "Display the status of a bug",
@@ -19,8 +17,8 @@ func newBugStatusCommand() *cobra.Command {
ValidArgsFunction: BugCompletion(env),
}
- cmd.AddCommand(newBugStatusCloseCommand())
- cmd.AddCommand(newBugStatusOpenCommand())
+ cmd.AddCommand(newBugStatusCloseCommand(env))
+ cmd.AddCommand(newBugStatusOpenCommand(env))
return cmd
}
diff --git a/commands/bug/bug_status_close.go b/commands/bug/bug_status_close.go
index e52959b2..1d06007b 100644
--- a/commands/bug/bug_status_close.go
+++ b/commands/bug/bug_status_close.go
@@ -6,9 +6,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBugStatusCloseCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugStatusCloseCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "close [BUG_ID]",
Short: "Mark a bug as closed",
diff --git a/commands/bug/bug_status_open.go b/commands/bug/bug_status_open.go
index 74177974..e99d2db0 100644
--- a/commands/bug/bug_status_open.go
+++ b/commands/bug/bug_status_open.go
@@ -6,9 +6,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBugStatusOpenCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugStatusOpenCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "open [BUG_ID]",
Short: "Mark a bug as open",
diff --git a/commands/bug/bug_title.go b/commands/bug/bug_title.go
index e59a1fdc..47603410 100644
--- a/commands/bug/bug_title.go
+++ b/commands/bug/bug_title.go
@@ -6,9 +6,7 @@ import (
"github.com/MichaelMure/git-bug/commands/execenv"
)
-func newBugTitleCommand() *cobra.Command {
- env := execenv.NewEnv()
-
+func newBugTitleCommand(env *execenv.Env) *cobra.Command {
cmd := &cobra.Command{
Use: "title [BUG_ID]",
Short: "Display the title of a bug",
@@ -19,7 +17,7 @@ func newBugTitleCommand() *cobra.Command {
ValidArgsFunction: BugCompletion(env),
}
- cmd.AddCommand(newBugTitleEditCommand())
+ cmd.AddCommand(newBugTitleEditCommand(env))
return cmd
}
diff --git a/commands/bug/bug_title_edit.go b/commands/bug/bug_title_edit.go
index 59898530..fc60824f 100644
--- a/commands/bug/bug_title_edit.go
+++ b/commands/bug/bug_title_edit.go
@@ -13,8 +13,7 @@ type bugTitleEditOptions struct {
nonInteractive bool
}
-func newBugTitleEditCommand() *cobra.Command {
- env := execenv.NewEnv()
+func newBugTitleEditCommand(env *execenv.Env) *cobra.Command {
options := bugTitleEditOptions{}
cmd := &cobra.Command{