Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #401 from maxice8/unlock-discussion
Browse files Browse the repository at this point in the history
Unlock discussion
  • Loading branch information
profclems authored Dec 23, 2020
2 parents f6476eb + 714f456 commit d118ca7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 12 additions & 4 deletions commands/issue/update/issue_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ 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")}
}
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 {
return err
Expand All @@ -46,6 +53,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)
}
Expand All @@ -55,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)
}
Expand All @@ -82,6 +89,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")
Expand Down
9 changes: 9 additions & 0 deletions commands/mr/update/mr_update.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package update

import (
"errors"
"fmt"
"strings"

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit d118ca7

Please sign in to comment.