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

Fix unassign #576

Merged
merged 4 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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