This repository has been archived by the owner on Dec 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show revision result in the project's commits page
Summary: If revision result is available for that commit, show it beside the build result. If it is not available, then use "unknown". Test Plan: ran locally + unit tests {F527506} Reviewers: kylec, anupc Reviewed By: anupc Subscribers: changesbot, kylec, wwu, anupc Tags: #changes_ui Differential Revision: https://tails.corp.dropbox.com/D232121
- Loading branch information
Naphat Sanguansin
committed
Sep 27, 2016
1 parent
783e2f4
commit b47f759
Showing
9 changed files
with
148 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
|
||
# register models | ||
from . import models # NOQA | ||
|
||
# register VCS | ||
from . import vcs # NOQA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
from __future__ import absolute_import | ||
|
||
from changes.api.serializer import Crumbler, register | ||
from changes.vcs.base import RevisionResult | ||
from changes.models.revisionresult import RevisionResult | ||
|
||
|
||
@register(RevisionResult) | ||
class RevisionCrumbler(Crumbler): | ||
class RevisionResultCrumbler(Crumbler): | ||
def crumble(self, instance, attrs): | ||
return { | ||
'id': instance.id, | ||
'sha': instance.id, # Having both id and sha is a bit distasteful. We should try to fix this. | ||
'message': instance.message, | ||
'author': None, # We don't return author information | ||
'dateCreated': instance.author_date, | ||
'dateCommitted': instance.committer_date, | ||
'id': instance.id.hex, | ||
'revisionSha': instance.revision_sha, | ||
'build': instance.build, | ||
'result': instance.result, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from changes.utils.imports import import_submodules | ||
|
||
import_submodules(globals(), __name__, __path__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from changes.api.serializer import Crumbler, register | ||
from changes.vcs.base import RevisionResult | ||
|
||
|
||
@register(RevisionResult) | ||
class RevisionCrumbler(Crumbler): | ||
def crumble(self, instance, attrs): | ||
return { | ||
'id': instance.id, | ||
'sha': instance.id, # Having both id and sha is a bit distasteful. We should try to fix this. | ||
'message': instance.message, | ||
'author': None, # We don't return author information | ||
'dateCreated': instance.author_date, | ||
'dateCommitted': instance.committer_date, | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/changes/api/serializer/models/test_revisionresult.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from changes.api.serializer import serialize | ||
from changes.testutils.cases import TestCase | ||
|
||
|
||
class RevisionResultCrumblerTestCase(TestCase): | ||
|
||
def test_simple(self): | ||
build = self.create_build(self.create_project()) | ||
revision_result = self.create_revision_result(build=build, revision_sha=build.source.revision_sha, project_id=build.project_id) | ||
|
||
data = serialize(revision_result) | ||
assert data['id'] == revision_result.id.hex | ||
assert data['revisionSha'] == revision_result.revision_sha | ||
assert data['build']['id'] == build.id.hex | ||
assert data['result']['id'] == 'unknown' | ||
|
||
def test_no_build(self): | ||
project = self.create_project() | ||
revision_result = self.create_revision_result(revision_sha='a' * 40, project_id=project.id) | ||
|
||
data = serialize(revision_result) | ||
assert data['id'] == revision_result.id.hex | ||
assert data['revisionSha'] == 'a' * 40 | ||
assert data['build'] is None | ||
assert data['result']['id'] == 'unknown' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters