Skip to content
Browse files

Handle updating missing revisions in poll_github command

  • Loading branch information...
1 parent 1902bda commit 3387a73b7786d345b56ca94d3f13d194ff8cf777 @dcramer dcramer committed Oct 31, 2012
Showing with 10 additions and 5 deletions.
  1. +1 −1 src/zumanji/helpers.py
  2. +1 −1 src/zumanji/importer.py
  3. +4 −1 src/zumanji/management/commands/poll_github.py
  4. +4 −2 src/zumanji/models.py
View
2 src/zumanji/helpers.py
@@ -172,6 +172,6 @@ def get_git_changes(build, previous_build):
previous_build.revision.label, build.revision.label)
commits = []
for commit in results['commits']:
- revision = Revision.get_or_create(build.project, commit['sha'])
+ revision = Revision.get_or_create(build.project, commit['sha'])[0]
commits.append(revision)
return commits
View
2 src/zumanji/importer.py
@@ -189,7 +189,7 @@ def import_build(data, project=None, revision=None):
revision = Revision.get_or_create(
project=project,
label=revision_label,
- )
+ )[0]
build, created = Build.objects.get_or_create(
project=project,
View
5 src/zumanji/management/commands/poll_github.py
@@ -14,4 +14,7 @@ def handle(self, **options):
for commit in github.iter_commits(project.github_user, project.github_repo):
print " Revision %r (%s; %s)" % (commit['sha'], commit['commit']['author']['name'],
commit['commit']['committer']['date'])
- Revision.get_or_create(project, commit['sha'])
+ rev, created = Revision.get_or_create(project, commit['sha'])
+ if not created and not rev.data:
+ rev.update_from_github()
+ rev.save()
View
6 src/zumanji/models.py
@@ -97,12 +97,14 @@ def get_or_create(cls, project, label):
"""
try:
rev = cls.objects.get(project=project, label=label)
+ created = False
except Revision.DoesNotExist:
rev = cls(project=project, label=label)
rev.update_from_github()
rev.save()
+ created = True
- return rev
+ return rev, created
@property
def details_url(self):
@@ -133,7 +135,7 @@ def update_from_github(self):
# LOL MULTIPLE PARENTS HOW DOES GIT WORK
# (dont care about the merge commits parent for our system)
if data.get('parents'):
- parent = type(self).get_or_create(self.project, data['parents'][0]['sha'])
+ parent = type(self).get_or_create(self.project, data['parents'][0]['sha'])[0]
else:
parent = None

0 comments on commit 3387a73

Please sign in to comment.
Something went wrong with that request. Please try again.