From 90377f19883e35e476b9213156b0be818d06346b Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 23 Dec 2020 13:14:18 -0300 Subject: [PATCH 1/3] feat(commands/issue/update): add --unlock-discussion flag acts as the opposite of --lock-discussion --- commands/issue/update/issue_update.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commands/issue/update/issue_update.go b/commands/issue/update/issue_update.go index 4c22901c..7745475b 100644 --- a/commands/issue/update/issue_update.go +++ b/commands/issue/update/issue_update.go @@ -28,6 +28,10 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { var err error out := f.IO.StdOut + if cmd.Flags().Changed("lock-discussion") && cmd.Flags().Changed("unlock-discussion") { + return &cmdutils.FlagError{Err: errors.New("--lock-discussion and --unlock-discussion can't be used together")} + } + apiClient, err := f.HttpClient() if err != nil { return err @@ -46,6 +50,10 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { if m, _ := cmd.Flags().GetBool("lock-discussion"); m { l.DiscussionLocked = gitlab.Bool(m) } + if m, _ := cmd.Flags().GetBool("unlock-discussion"); m { + l.DiscussionLocked = gitlab.Bool(false) + } + if m, _ := cmd.Flags().GetString("description"); m != "" { l.Description = gitlab.String(m) } @@ -82,6 +90,7 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { issueUpdateCmd.Flags().StringP("title", "t", "", "Title of issue") issueUpdateCmd.Flags().BoolP("lock-discussion", "", false, "Lock discussion on issue") + issueUpdateCmd.Flags().BoolP("unlock-discussion", "", false, "Unlock discussion on issue") issueUpdateCmd.Flags().StringP("description", "d", "", "Issue description") issueUpdateCmd.Flags().StringArrayP("label", "l", []string{}, "add labels") issueUpdateCmd.Flags().StringArrayP("unlabel", "u", []string{}, "remove labels") From d4a3550942c2c14f24b2a3914cd725ec6aebb232 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 23 Dec 2020 13:19:55 -0300 Subject: [PATCH 2/3] feat(commands/mr/update): add --unlock-discussion flag acts as the opposite of --lock-discussion --- commands/mr/update/mr_update.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commands/mr/update/mr_update.go b/commands/mr/update/mr_update.go index 2c55ab97..b07b79ad 100644 --- a/commands/mr/update/mr_update.go +++ b/commands/mr/update/mr_update.go @@ -1,6 +1,7 @@ package update import ( + "errors" "fmt" "strings" @@ -27,6 +28,10 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { var err error + if cmd.Flags().Changed("lock-discussion") && cmd.Flags().Changed("unlock-discussion") { + return &cmdutils.FlagError{Err: errors.New("--lock-discussion and --unlock-discussion can't be used together")} + } + apiClient, err := f.HttpClient() if err != nil { return err @@ -73,6 +78,9 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { if m, _ := cmd.Flags().GetBool("lock-discussion"); m { l.DiscussionLocked = gitlab.Bool(m) } + if m, _ := cmd.Flags().GetBool("unlock-discussion"); m { + l.DiscussionLocked = gitlab.Bool(false) + } if m, _ := cmd.Flags().GetString("description"); m != "" { l.Description = gitlab.String(m) @@ -105,6 +113,7 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { mrUpdateCmd.Flags().BoolP("wip", "", false, "Mark merge request as a work in progress. Alternative to --draft") mrUpdateCmd.Flags().StringP("title", "t", "", "Title of merge request") mrUpdateCmd.Flags().BoolP("lock-discussion", "", false, "Lock discussion on merge request") + mrUpdateCmd.Flags().BoolP("unlock-discussion", "", false, "Unlock discussion on merge request") mrUpdateCmd.Flags().StringP("description", "d", "", "merge request description") mrUpdateCmd.Flags().StringSliceP("assignees", "a", []string{}, "Assign merge request to people by their `usernames`") mrUpdateCmd.Flags().BoolP("remove-source-branch", "", false, "Remove Source Branch on merge") From 714f456d79ff94e58f49e9ad2888b1b604f64ad7 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 23 Dec 2020 14:45:03 -0300 Subject: [PATCH 3/3] fix(commands/issue/update): check flag conflicts before anything --- commands/issue/update/issue_update.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/commands/issue/update/issue_update.go b/commands/issue/update/issue_update.go index 7745475b..391a067e 100644 --- a/commands/issue/update/issue_update.go +++ b/commands/issue/update/issue_update.go @@ -31,6 +31,9 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { if cmd.Flags().Changed("lock-discussion") && cmd.Flags().Changed("unlock-discussion") { return &cmdutils.FlagError{Err: errors.New("--lock-discussion and --unlock-discussion can't be used together")} } + if cmd.Flags().Changed("confidential") && cmd.Flags().Changed("public") { + return &cmdutils.FlagError{Err: errors.New("--public and --confidential can't be used together")} + } apiClient, err := f.HttpClient() if err != nil { @@ -63,10 +66,6 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command { if m, _ := cmd.Flags().GetStringArray("unlabel"); len(m) != 0 { l.RemoveLabels = gitlab.Labels(m) } - - if cmd.Flags().Changed("confidential") && cmd.Flags().Changed("public") { - return &cmdutils.FlagError{Err: errors.New("--public and --confidential can't be used together")} - } if m, _ := cmd.Flags().GetBool("public"); m { l.Confidential = gitlab.Bool(false) }