Skip to content

Commit

Permalink
Merge pull request #3 from 2-shell/feature/add-argument-to-control-mr…
Browse files Browse the repository at this point in the history
…-state-for-listing

Add argument to control mr state for listing
  • Loading branch information
Adriks976 authored Aug 24, 2020
2 parents 239d5fd + 53a8708 commit f3faaef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gitlab-manager
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class MergeRequest:
def print_mr(self):
return "### {}: {}\n\n{}\n\n * by: {}\n\n * Merge Request ID:{}\n".format(self.Label, self.Title, self.Description, self.Author, self.Id)

def list_mrs(project, wip):
def list_mrs(project, state, wip):
print("\nHere is the list of MRs for your chosen project:\n")
mrs = project.mergerequests.list(state='opened', order_by='updated_at', wip=wip)
mrs = project.mergerequests.list(state=state, order_by='updated_at', wip=wip)
all_mr = []
for mr in mrs:
current = MergeRequest(mr)
Expand Down Expand Up @@ -104,6 +104,10 @@ def init_argparse():
ls_mr = subparsers.add_parser('ls')
ls_mr.add_argument("--wip", dest='wip', action='store', type=str,
help='search wip or not', choices=['yes', 'no'])
ls_mr.add_argument("--state", dest='state', action='store', type=str,
help='filter for the specified state',
choices=['all', 'opened', 'closed', 'locked', 'merged'],
default='opened')
update_mr = subparsers.add_parser('update')
update_mr.add_argument('mr_id')
update_mr.add_argument("--label", dest='label', action='store', type=str,
Expand Down Expand Up @@ -166,7 +170,7 @@ if __name__ == '__main__':
project = projects[0]
if args.command == "mr":
if args.action == "ls":
list_mrs(project, args.wip)
list_mrs(project, args.state, args.wip)
if args.action == "update":
update_mr(project, args.mr_id, args.label, args.tag)
if args.command == "changelog":
Expand Down

0 comments on commit f3faaef

Please sign in to comment.