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 #576 from maxice8/fix-unassign
Browse files Browse the repository at this point in the history
Fix unassign
  • Loading branch information
maxice8 authored Jan 17, 2021
2 parents ec09de9 + d4b64ab commit a97419c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
13 changes: 6 additions & 7 deletions commands/issue/update/issue_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
var ua *cmdutils.UserAssignments
out := f.IO.StdOut

if cmd.Flags().Changed("unassign") {
if cmd.Flags().Changed("assignee") {
return &cmdutils.FlagError{Err: fmt.Errorf("--assignee and --unassign are mutually exclusive")}
}
ua = &cmdutils.UserAssignments{
ToReplace: []string{"0"},
}
if cmd.Flags().Changed("unassign") && cmd.Flags().Changed("assignee") {
return &cmdutils.FlagError{Err: fmt.Errorf("--assignee and --unassign are mutually exclusive")}
}

// Parse assignees Early so we can fail early in case of conflicts
Expand Down Expand Up @@ -118,6 +113,10 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
l.MilestoneID = gitlab.Int(0)
}
}
if cmd.Flags().Changed("unassign") {
l.AssigneeIDs = []int{0} // 0 or an empty int[] is the documented way to unassign
actions = append(actions, "unassigned all users")
}
if ua != nil {
if len(ua.ToReplace) != 0 {
l.AssigneeIDs, actions, err = ua.UsersFromReplaces(apiClient, actions)
Expand Down
11 changes: 6 additions & 5 deletions commands/mr/update/mr_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
var actions []string
var ua *cmdutils.UserAssignments

if cmd.Flags().Changed("unassign") {
if cmd.Flags().Changed("assignee") {
return &cmdutils.FlagError{Err: fmt.Errorf("--assignee and --unassign are mutually exclusive")}
}
ua.ToReplace = []string{"0"}
if cmd.Flags().Changed("unassign") && cmd.Flags().Changed("assignee") {
return &cmdutils.FlagError{Err: fmt.Errorf("--assignee and --unassign are mutually exclusive")}
}

// Parse assignees Early so we can fail early in case of conflicts
Expand Down Expand Up @@ -139,6 +136,10 @@ func NewCmdUpdate(f *cmdutils.Factory) *cobra.Command {
l.MilestoneID = gitlab.Int(0)
}
}
if cmd.Flags().Changed("unassign") {
l.AssigneeIDs = []int{0} // 0 or an empty int[] is the documented way to unassign
actions = append(actions, "unassigned all users")
}
if ua != nil {
if len(ua.ToReplace) != 0 {
l.AssigneeIDs, actions, err = ua.UsersFromReplaces(apiClient, actions)
Expand Down

0 comments on commit a97419c

Please sign in to comment.