Print more problems

This commit is contained in:
Ivan Lezhankin 2019-04-08 19:11:13 +03:00
parent be23dff3b0
commit 5a909b01b0
2 changed files with 21 additions and 6 deletions

View File

@ -27,7 +27,6 @@
from . import local, query
import argparse
from pprint import pprint
import sys
@ -49,12 +48,17 @@ repo = local.Local(args.repo, args.remote, github.get_default_branch())
stables = repo.get_stables()[-args.number:]
if not stables:
sys.exit('No stable branches found!')
else:
print('Found stable branches:')
for stable in stables:
print(f'{stable[0]} forked from {stable[1]}')
first_commit = max(repo.get_first_commit(), stables[0][1], key=repo.comparator)
pull_requests = github.get_pull_requests(first_commit)
good_commits = set(oid[0] for oid in pull_requests.values())
pprint(good_commits)
print()
print('Problems:')
# Iterate all local commits on portions: from HEAD to 1st recent stable base, then to 2nd recent base, and so on.
# It will help to detect necessity to cherry-pick or backport something to previous stable branches.
@ -65,6 +69,17 @@ for i in reversed(range(len(stables))):
for commit in repo.iterate(from_commit, stables[i][1]):
if str(commit) not in good_commits:
print(f'Commit {commit} is not referenced by any pull-request!', file=sys.stderr)
print(f'commit {commit} is not referenced by any pull-request', file=sys.stderr)
from_commit = stables[i][1]
for num, value in pull_requests.items():
label_found = False
for label in value[1]:
if label.startswith('pr-'):
label_found = True
break
if not label_found:
print(f'pull-request {num} has no description label', file=sys.stderr)

View File

@ -44,13 +44,13 @@ class Query:
def get_default_branch(self):
return self._run(Query._DEFAULT)['data']['repository']['defaultBranchRef']['name']
def _labels(self, pr):
pass
def _labels(self, pull_request):
# TODO: fetch all labels
return [label['node']['name'] for label in pull_request['labels']['edges']]
def _run(self, query):
headers = {'Authorization': f'bearer {self._token}'}
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
print('Running query…')
if request.status_code == 200:
return request.json()
else: