Skip to content

Commit

Permalink
mr_list: Allow filtering by draft status
Browse files Browse the repository at this point in the history
The draft status is a useful filter (looking for MRs to pick up or
review), so add corresponding options.
  • Loading branch information
fmuellner authored and prarit committed Dec 14, 2020
1 parent b4f4d18 commit 4b72ab8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/mr_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var (
mrNumRet int
mrAll bool
mrMine bool
mrDraft bool
mrReady bool
assigneeID *int
mrAssignee string
order string
Expand Down Expand Up @@ -74,7 +76,7 @@ func mrList(args []string) ([]*gitlab.MergeRequest, error) {

sort := gitlab.String(sortedBy)

return lab.MRList(rn, gitlab.ListProjectMergeRequestsOptions{
opts := gitlab.ListProjectMergeRequestsOptions{
ListOptions: gitlab.ListOptions{
PerPage: mrNumRet,
},
Expand All @@ -84,7 +86,15 @@ func mrList(args []string) ([]*gitlab.MergeRequest, error) {
OrderBy: orderBy,
Sort: sort,
AssigneeID: assigneeID,
}, num)
}

if mrDraft && !mrReady {
opts.WIP = gitlab.String("yes")
} else if mrReady && !mrDraft {
opts.WIP = gitlab.String("no")
}

return lab.MRList(rn, opts, num)
}

func init() {
Expand All @@ -105,6 +115,8 @@ func init() {
&mrAssignee, "assignee", "", "list only MRs assigned to $username")
listCmd.Flags().StringVar(&order, "order", "updated_at", "display order, updated_at(default) or created_at")
listCmd.Flags().StringVar(&sortedBy, "sort", "desc", "sort order, desc(default) or asc")
listCmd.Flags().BoolVarP(&mrDraft, "draft", "", false, "list MRs marked as draft")
listCmd.Flags().BoolVarP(&mrReady, "ready", "", false, "list MRs not marked as draft")

mrCmd.AddCommand(listCmd)
carapace.Gen(listCmd).FlagCompletion(carapace.ActionMap{
Expand Down

0 comments on commit 4b72ab8

Please sign in to comment.