Allow filtering mr list by draft and not draft status

Problem to Solve

mr list has draft flag to filter drafts:

➜ gl mr list --help|grep draft
  -d, --draft                  Filter by draft merge requests

This currently only allows you to filter the mr list to only show you draft MRs:

$ glab mr list

Showing 12 open merge requests on gitlab-org/cli (Page 1)

!1062  chore: add linting for commit messages                             (main) ← (phikai-lint-commits)
!1060  Draft: docs: generate docs on tagged release                       (main) ← (phikai-automatic-doc-generation)
!1054  Fix issue URL parser to support nested groups                      (main) ← (fix-invalid-issue-url)
!1049  feat: add no-duplicate flag                                        (main) ← (check-duplicates)
!1047  Add zip files to gitignore                                         (main) ← (gmh-add-zip-to-gitignore)
!1046  Avoid running manual job (in ci view) if the user press 'esc'      (main) ← (fix/ci-view-manual)
!1034  feat: add GITLAB_GROUP override to issue/mr/variable list (#1057)  (main) ← (feat/1057/group-override-with-env-var)
!1031  Draft: Json output                                                 (main) ← (json-output)
!1028  gpg-key command                                                    (main) ← (gpg-key_support)
!1017  feat: 'issue board view' command support for group boards          (main) ← (add-group-issue-boards)
!1012  do not navigate when we don't have jobs loaded yet                 (main) ← (glab_segf)
!1000  Extend "pipeline" command functions                                (main) ← (get-pipeline)

Where if you add --draft you get the following:

$ glab mr list --draft

Showing 2 open merge requests in gitlab-org/cli that match your search (Page 1)

!1060  Draft: docs: generate docs on tagged release  (main) ← (phikai-automatic-doc-generation)
!1031  Draft: Json output                            (main) ← (json-output)

Proposal

There should be a way to list the MRs that are NOT in draft status. Potential options would be to change --draft to accept a true/false param or to add a --not-draft command.

Implementation plan

Add new filter to: https://gitlab.com/gitlab-org/cli/-/blob/96b5fcb0f2802a69176b0e2aefa1f525f0139c0d/commands/issuable/list/issuable_list.go#L164-164

Add test for filter

Edited Nov 04, 2024 by Jay McCure
Assignee Loading
Time tracking Loading