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 #551 from maxice8/mr-list
Browse files Browse the repository at this point in the history
mr list
  • Loading branch information
maxice8 authored Jan 9, 2021
2 parents c2ae375 + ba7de81 commit f5d8f91
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions commands/mr/list/mr_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ListOptions struct {
Assignee []string
Author string
Labels []string
NotLabels []string
Milestone string
SourceBranch string
TargetBranch string
Expand Down Expand Up @@ -60,16 +61,26 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error) *cobra.
Example: heredoc.Doc(`
$ glab mr list --all
$ glab mr ls -a
$ glab mr list --mine
$ glab mr list --assignee=@me
$ glab mr list --source-branch=new-feature
$ glab mr list --target-branch=trunk
$ glab mr list --search "this adds feature X"
$ glab mr list --label needs-review
$ glab mr list -o --per-page 10
$ glab mr list --not-label waiting-maintainer-feedback,subsystem-x
$ glab mr list -M --per-page 10
`),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
// supports repo override
opts.BaseRepo = f.BaseRepo
opts.HTTPClient = f.HttpClient

if len(opts.Labels) != 0 && len(opts.NotLabels) != 0 {
return cmdutils.FlagError{
Err: errors.New("flags --label and --not-label are mutually exclusive"),
}
}

// check if any of the two or all of states flag are specified
if opts.Closed && opts.Merged {
return cmdutils.FlagError{
Expand Down Expand Up @@ -98,6 +109,7 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error) *cobra.
}

mrListCmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", []string{}, "Filter merge request by label <name>")
mrListCmd.Flags().StringSliceVar(&opts.NotLabels, "not-label", []string{}, "Filter merge requests by not having label <name>")
mrListCmd.Flags().StringVar(&opts.Author, "author", "", "Fitler merge request by Author <username>")
mrListCmd.Flags().StringVarP(&opts.Milestone, "milestone", "m", "", "Filter merge request by milestone <id>")
mrListCmd.Flags().StringVarP(&opts.SourceBranch, "source-branch", "s", "", "Filter by source branch <name>")
Expand Down

0 comments on commit f5d8f91

Please sign in to comment.