Add --unmerged

This commit is contained in:
Laurent Rineau 2016-10-04 20:06:51 +02:00
parent b27f3b75fc
commit d78eb5192f
1 changed files with 14 additions and 4 deletions

View File

@ -31,6 +31,8 @@ Print the URLs or CGAL pull-request with a given label.''',\
user=lrineau user=lrineau
token=7f3f81294bd965232ca3c657a23c16729dac663f token=7f3f81294bd965232ca3c657a23c16729dac663f
Go to https://github.com/settings/tokens to create a token.
'''.format(config_file))) '''.format(config_file)))
parser.add_argument('label', metavar='label', type=str, parser.add_argument('label', metavar='label', type=str,
help='the label used to select pull requests.\ help='the label used to select pull requests.\
@ -38,6 +40,8 @@ parser.add_argument('label', metavar='label', type=str,
is added as a prefix.') is added as a prefix.')
parser.add_argument('--verbose', action='store_const', const=True, parser.add_argument('--verbose', action='store_const', const=True,
help='display verbose outputs to stderr') help='display verbose outputs to stderr')
parser.add_argument('--unmerged', action='store_const', const=True,
help='show only unmerged pull-requests')
args = parser.parse_args() args = parser.parse_args()
def print_verbose(str, *argv, **kwargs): def print_verbose(str, *argv, **kwargs):
@ -48,6 +52,7 @@ def print_verbose(str, *argv, **kwargs):
u=config['main']['user'] u=config['main']['user']
s=config['main']['token'] s=config['main']['token']
verbose=args.verbose verbose=args.verbose
unmerged=args.unmerged
print_verbose("Getting commits in current branch", end='') print_verbose("Getting commits in current branch", end='')
sys.stderr.flush() sys.stderr.flush()
@ -100,7 +105,12 @@ for issue in cgal.get_issues(labels=[Ic]):
.format(issue.number, label_name)) .format(issue.number, label_name))
for nb in issues.keys(): for nb in issues.keys():
print(issues[nb]["url"])
if issues[nb]["sha"] not in commits: if issues[nb]["sha"] not in commits:
if(unmerged):
print(issues[nb]["url"])
else:
print_verbose("Warning: {} head {} is not in the current branch".\ print_verbose("Warning: {} head {} is not in the current branch".\
format(issues[nb]["url"], issues[nb]["sha"])) format(issues[nb]["url"], issues[nb]["sha"]))
else:
if(not unmerged):
print(issues[nb]["url"])