Show More
@@ -588,6 +588,7 b' INPUT::' | |||||
588 | args: { |
|
588 | args: { | |
589 | "repoid" : "<reponame or repo_id>", |
|
589 | "repoid" : "<reponame or repo_id>", | |
590 | "with_revision_names": "<bool> = Optional(False)", |
|
590 | "with_revision_names": "<bool> = Optional(False)", | |
|
591 | "with_pullrequests": "<bool> = Optional(False)", | |||
591 | } |
|
592 | } | |
592 |
|
593 | |||
593 | OUTPUT:: |
|
594 | OUTPUT:: | |
@@ -672,6 +673,55 b' OUTPUT::' | |||||
672 | "<bookmarkname>": "<raw_id>", |
|
673 | "<bookmarkname>": "<raw_id>", | |
673 | ... |
|
674 | ... | |
674 | }, |
|
675 | }, | |
|
676 | <if with_pullrequests == True> | |||
|
677 | "pull_requests": [ | |||
|
678 | { | |||
|
679 | "status": "<pull_request_status>", | |||
|
680 | "pull_request_id": <pull_request_id>, | |||
|
681 | "description": "<pull_request_description>", | |||
|
682 | "title": "<pull_request_title>", | |||
|
683 | "url": "<pull_request_url>", | |||
|
684 | "reviewers": [ | |||
|
685 | { | |||
|
686 | "username": "<user_id>", | |||
|
687 | }, | |||
|
688 | ... | |||
|
689 | ], | |||
|
690 | "org_repo_url": "<repo_url>", | |||
|
691 | "org_ref_parts": [ | |||
|
692 | "<ref_type>", | |||
|
693 | "<ref_name>", | |||
|
694 | "<raw_id>" | |||
|
695 | ], | |||
|
696 | "other_ref_parts": [ | |||
|
697 | "<ref_type>", | |||
|
698 | "<ref_name>", | |||
|
699 | "<raw_id>" | |||
|
700 | ], | |||
|
701 | "comments": [ | |||
|
702 | { | |||
|
703 | "username": "<user_id>", | |||
|
704 | "text": "<comment text>", | |||
|
705 | "comment_id": "<comment_id>", | |||
|
706 | }, | |||
|
707 | ... | |||
|
708 | ], | |||
|
709 | "owner": "<username>", | |||
|
710 | "statuses": [ | |||
|
711 | { | |||
|
712 | "status": "<status_of_review>", # "under_review", "approved" or "rejected" | |||
|
713 | "reviewer": "<user_id>", | |||
|
714 | "modified_at": "<date_time_of_review>" # iso 8601 date, server's timezone | |||
|
715 | }, | |||
|
716 | ... | |||
|
717 | ], | |||
|
718 | "revisions": [ | |||
|
719 | "<raw_id>", | |||
|
720 | ... | |||
|
721 | ] | |||
|
722 | }, | |||
|
723 | ... | |||
|
724 | ] | |||
675 | } |
|
725 | } | |
676 | error: null |
|
726 | error: null | |
677 |
|
727 |
@@ -1126,7 +1126,8 b' class ApiController(JSONRPCController):' | |||||
1126 |
|
1126 | |||
1127 | # permission check inside |
|
1127 | # permission check inside | |
1128 | def get_repo(self, repoid, |
|
1128 | def get_repo(self, repoid, | |
1129 |
with_revision_names=Optional(False) |
|
1129 | with_revision_names=Optional(False), | |
|
1130 | with_pullrequests=Optional(False)): | |||
1130 | """ |
|
1131 | """ | |
1131 | Gets an existing repository by it's name or repository_id. Members will return |
|
1132 | Gets an existing repository by it's name or repository_id. Members will return | |
1132 | either users_group or user associated to that repository. This command can be |
|
1133 | either users_group or user associated to that repository. This command can be | |
@@ -1227,7 +1228,8 b' class ApiController(JSONRPCController):' | |||||
1227 | for uf in repo.followers |
|
1228 | for uf in repo.followers | |
1228 | ] |
|
1229 | ] | |
1229 |
|
1230 | |||
1230 |
data = repo.get_api_data(with_revision_names=Optional.extract(with_revision_names) |
|
1231 | data = repo.get_api_data(with_revision_names=Optional.extract(with_revision_names), | |
|
1232 | with_pullrequests=Optional.extract(with_pullrequests)) | |||
1231 | data['members'] = members |
|
1233 | data['members'] = members | |
1232 | data['followers'] = followers |
|
1234 | data['followers'] = followers | |
1233 | return data |
|
1235 | return data |
@@ -1246,10 +1246,11 b' class Repository(Base, BaseDbModel):' | |||||
1246 |
|
1246 | |||
1247 | return is_valid_repo(repo_name, cls.base_path()) |
|
1247 | return is_valid_repo(repo_name, cls.base_path()) | |
1248 |
|
1248 | |||
1249 |
def get_api_data(self, with_revision_names=False |
|
1249 | def get_api_data(self, with_revision_names=False, | |
|
1250 | with_pullrequests=False): | |||
1250 | """ |
|
1251 | """ | |
1251 | Common function for generating repo api data. |
|
1252 | Common function for generating repo api data. | |
1252 |
Optionally, also return tags, branches |
|
1253 | Optionally, also return tags, branches, bookmarks and PRs. | |
1253 | """ |
|
1254 | """ | |
1254 | repo = self |
|
1255 | repo = self | |
1255 | data = dict( |
|
1256 | data = dict( | |
@@ -1279,6 +1280,8 b' class Repository(Base, BaseDbModel):' | |||||
1279 | branches=scm_repo.branches, |
|
1280 | branches=scm_repo.branches, | |
1280 | bookmarks=scm_repo.bookmarks, |
|
1281 | bookmarks=scm_repo.bookmarks, | |
1281 | )) |
|
1282 | )) | |
|
1283 | if with_pullrequests: | |||
|
1284 | data['pull_requests'] = repo.pull_requests_other | |||
1282 | rc_config = Setting.get_app_settings() |
|
1285 | rc_config = Setting.get_app_settings() | |
1283 | repository_fields = str2bool(rc_config.get('repository_fields')) |
|
1286 | repository_fields = str2bool(rc_config.get('repository_fields')) | |
1284 | if repository_fields: |
|
1287 | if repository_fields: |
@@ -777,6 +777,7 b' class _BaseTestApi(object):' | |||||
777 | repoid=self.REPO) |
|
777 | repoid=self.REPO) | |
778 | response = api_call(self, params) |
|
778 | response = api_call(self, params) | |
779 | assert u"tags" not in response.json[u'result'] |
|
779 | assert u"tags" not in response.json[u'result'] | |
|
780 | assert u'pull_requests' not in response.json[u'result'] | |||
780 |
|
781 | |||
781 | repo = RepoModel().get_by_repo_name(self.REPO) |
|
782 | repo = RepoModel().get_by_repo_name(self.REPO) | |
782 | ret = repo.get_api_data() |
|
783 | ret = repo.get_api_data() | |
@@ -808,9 +809,11 b' class _BaseTestApi(object):' | |||||
808 | fixture.destroy_user_group(new_group) |
|
809 | fixture.destroy_user_group(new_group) | |
809 |
|
810 | |||
810 | id_, params = _build_data(self.apikey, 'get_repo', repoid=self.REPO, |
|
811 | id_, params = _build_data(self.apikey, 'get_repo', repoid=self.REPO, | |
811 |
with_revision_names=True |
|
812 | with_revision_names=True, | |
|
813 | with_pullrequests=True) | |||
812 | response = api_call(self, params) |
|
814 | response = api_call(self, params) | |
813 | assert u"v0.2.0" in response.json[u'result'][u'tags'] |
|
815 | assert u"v0.2.0" in response.json[u'result'][u'tags'] | |
|
816 | assert u'pull_requests' in response.json[u'result'] | |||
814 |
|
817 | |||
815 | @parametrize('grant_perm', [ |
|
818 | @parametrize('grant_perm', [ | |
816 | ('repository.admin'), |
|
819 | ('repository.admin'), |
General Comments 0
You need to be logged in to leave comments.
Login now