Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add argument to control mr state for listing #3

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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