summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2017-09-21 11:54:09 -0500
committerAndy Doan <andy.doan@linaro.org>2017-09-21 12:06:08 -0500
commit09afc666057e6346148e4f9ac65cbbf186998221 (patch)
treebd7ee53eb809d65ff133193ad76e993e0aa760ce
parentd8bd0c60487e722f8cc258826fc592df5169c99b (diff)
downloadpatchwork-tools-09afc666057e6346148e4f9ac65cbbf186998221.tar.gz
github: Fix totally broken script
There were a few bugs at play: 1) Only first run of a project would get results The sorting logic was backwards, so the first entry was an old run and we'd exit. 2) create_tags was totally broke It was passing in the wrong dictionary to the Commit constructor 3) Not sure about the real source tcs[0] was causing an index error. That meant the patch existed but the user had no team credits. This is probably just showing up now because I had to rerun the script with back-dated dates to pick up all the patches we'd missed. Change-Id: If94df85b36810b5cd84f721b42aac1095054e1d8
-rwxr-xr-xlinaro_metrics/sync_github_changes.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/linaro_metrics/sync_github_changes.py b/linaro_metrics/sync_github_changes.py
index 6050c18..e37f55e 100755
--- a/linaro_metrics/sync_github_changes.py
+++ b/linaro_metrics/sync_github_changes.py
@@ -55,7 +55,7 @@ class Commit(object):
def __init__(self, sha, message, author):
self.id = sha
self.message = message
- self.commit_author = '%s <%s>' % (author['name'], author['email'])
+ self.author = '%s <%s>' % (author['name'], author['email'])
dt = datetime.strptime(author['date'], '%Y-%m-%dT%H:%M:%SZ')
self.commit_time = int(time.mktime(dt.timetuple()))
self.commit_timezone = 0
@@ -73,7 +73,8 @@ def _get(url):
def get_pull_requests(owner, repo, last_update=None):
- url = 'https://api.github.com/repos/%s/%s/pulls?state=all&sort=updated'
+ url = 'https://api.github.com/repos/%s/%s/pulls'
+ url += '?state=all&sort=updated&direction=desc'
url = url % (owner, repo)
while url:
resp = _get(url)
@@ -140,6 +141,9 @@ def create_or_update(proj, owner, repo, author, pr):
p.save()
TeamCredit.objects.filter(patch=p).update(
last_state_change=updated)
+ except IndexError:
+ # No team credit exists for patch, ie tcs[0].last_state_change failed
+ TeamCredit.objects.filter(patch=p).update(last_state_change=updated)
except Patch.DoesNotExist:
fields['msgid'] = msgid
fields['date'] = created
@@ -174,8 +178,8 @@ def repo_cache():
def create_tags(crowd, project, commits):
for commit in commits:
- c = Commit(
- commit['sha'], commit['commit']['message'], commit['author'])
+ c = Commit(commit['sha'], commit['commit']['message'],
+ commit['commit']['author'])
team_project_credit.update_commit_callback(
crowd, project, None, c, False)
@@ -196,7 +200,7 @@ def main(args):
commits = get_commits(pr)
auth = get_author(crwd, commits)
if auth:
- log.debug('checking change: %d', pr['number'])
+ log.info('checking change: %d', pr['number'])
create_or_update(proj, owner, repo, auth, pr)
project = Project.objects.get(name=proj)
create_tags(crwd, project, commits)