improve the script

- More verbose outputs
- Compatibility with various versions of dulwich.
This commit is contained in:
Laurent Rineau 2016-10-06 18:22:28 +02:00
parent 5e3a7dba70
commit 6c93f66b1f
1 changed files with 16 additions and 7 deletions

View File

@ -1,7 +1,7 @@
#! /bin/env python3 #! /bin/env python3
from __future__ import print_function from __future__ import print_function
from builtins import (bytes) from builtins import (bytes, str)
import github, sys, os, configparser, argparse, textwrap import github, sys, os, configparser, argparse, textwrap
from github import Github, Label, Issue, PullRequest from github import Github, Label, Issue, PullRequest
@ -54,11 +54,21 @@ s=config['main']['token']
verbose=args.verbose verbose=args.verbose
unmerged=args.unmerged unmerged=args.unmerged
print_verbose("Getting commits in current branch", end='')
sys.stderr.flush() sys.stderr.flush()
repo = Repo.discover() repo = Repo.discover()
print_verbose(" branch: {}".format(repo.refs.read_ref('HEAD')),\ print_verbose("Found Git repository {}".format(repo))
end='') print_verbose(" control dir is {}".format(repo.controldir()))
try:
repo.commondir
except AttributeError:
print_verbose("dulwich does not know repo.commondir()")
else:
print_verbose(" common dir is {}".format(repo.commondir()))
print_verbose(" index path is {}".format(repo.index_path()))
print_verbose("Getting commits in current branch", end='')
print_verbose(" {}".\
format(str(repo.refs.read_ref('HEAD'), "ascii")), end='')
sys.stderr.flush() sys.stderr.flush()
walk = repo.get_walker(include=repo.head(),\ walk = repo.get_walker(include=repo.head(),\
exclude=[repo.get_refs()[b'refs/remotes/cgal/master']]) exclude=[repo.get_refs()[b'refs/remotes/cgal/master']])
@ -106,9 +116,8 @@ for issue in cgal.get_issues(labels=[Ic]):
for nb in issues.keys(): for nb in issues.keys():
if issues[nb]["sha"] not in commits: if issues[nb]["sha"] not in commits:
if(unmerged): print(issues[nb]["url"])
print(issues[nb]["url"]) if(not unmerged):
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: else: