Skip to content

Commit

Permalink
mr list: Add --order option
Browse files Browse the repository at this point in the history
'mr list' lists merge requests in order of the time they were updated, and
doesn't provide an option to list them by numerical order (ie, time they
were created).

Add a --order option to mr list to display the merge requests in

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
  • Loading branch information
prarit committed Dec 8, 2020
1 parent 845de95 commit 750e04a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/mr_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
mrMine bool
assigneeID *int
mrAssignee string
order string
)

// listCmd represents the list command
Expand Down Expand Up @@ -68,14 +69,16 @@ func mrList(args []string) ([]*gitlab.MergeRequest, error) {
assigneeID = &_assigneeID
}

orderBy := gitlab.String(order)

return lab.MRList(rn, gitlab.ListProjectMergeRequestsOptions{
ListOptions: gitlab.ListOptions{
PerPage: mrNumRet,
},
Labels: mrLabels,
State: &mrState,
TargetBranch: &mrTargetBranch,
OrderBy: gitlab.String("updated_at"),
OrderBy: orderBy,
AssigneeID: assigneeID,
}, num)
}
Expand All @@ -96,6 +99,7 @@ func init() {
listCmd.Flags().BoolVarP(&mrMine, "mine", "m", false, "list only MRs assigned to me")
listCmd.Flags().StringVar(
&mrAssignee, "assignee", "", "list only MRs assigned to $username")
listCmd.Flags().StringVar(&order, "order", "updated_at", "display order, updated_at(default) or created_at")

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

0 comments on commit 750e04a

Please sign in to comment.