reviewers: use target repo owner as default reviewer in case of CE edition....
marcink -
r3230:3c9caf8e default
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -66,7 +66,7
66 66 expected_message = "Created new pull request `{title}`".format(
67 67 title=data['title'])
68 68 result = response.json
69 assert result['error'] == None
69 assert result['error'] is None
70 70 assert result['result']['msg'] == expected_message
71 71 pull_request_id = result['result']['pull_request_id']
72 72 pull_request = PullRequestModel().get(pull_request_id)
@@ -89,7 +89,7
89 89 expected_message = "Created new pull request `{title}`".format(
90 90 title=data['title'])
91 91 result = response.json
92 assert result['error'] == None
92 assert result['error'] is None
93 93 assert result['result']['msg'] == expected_message
94 94 pull_request_id = result['result']['pull_request_id']
95 95 pull_request = PullRequestModel().get(pull_request_id)
@@ -129,7 +129,7
129 129 expected_message = "Created new pull request `{title}`".format(
130 130 title=data['title'])
131 131 result = response.json
132 assert result['error'] == None
132 assert result['error'] is None
133 133 assert result['result']['msg'] == expected_message
134 134 pull_request_id = result['result']['pull_request_id']
135 135 pull_request = PullRequestModel().get(pull_request_id)
@@ -144,11 +144,15
144 144 entry['mandatory'] = rev.mandatory
145 145 actual_reviewers.append(entry)
146 146
147 # default reviewer will be added who is an owner of the repo
148 reviewers.append(
149 {'username': pull_request.author.username,
150 'reasons': [u'Default reviewer', u'Repository owner']},
151 )
147 owner_username = pull_request.target_repo.user.username
148 for spec_reviewer in reviewers[::]:
149 # default reviewer will be added who is an owner of the repo
150 # this get's overridden by a add owner to reviewers rule
151 if spec_reviewer['username'] == owner_username:
152 spec_reviewer['reasons'] = [u'Default reviewer', u'Repository owner']
153 # since owner is more important, we don't inherit mandatory flag
154 del spec_reviewer['mandatory']
155
152 156 assert sorted(actual_reviewers, key=lambda e: e['username']) \
153 157 == sorted(reviewers, key=lambda e: e['username'])
154 158
@@ -173,7 +177,7
173 177 expected_message = "Created new pull request `{title}`".format(
174 178 title=data['title'])
175 179 result = response.json
176 assert result['error'] == None
180 assert result['error'] is None
177 181 assert result['result']['msg'] == expected_message
178 182 pull_request_id = result['result']['pull_request_id']
179 183 pull_request = PullRequestModel().get(pull_request_id)
@@ -187,11 +191,14
187 191 if rev.mandatory:
188 192 entry['mandatory'] = rev.mandatory
189 193 actual_reviewers.append(entry)
190 # default reviewer will be added who is an owner of the repo
191 reviewers.append(
192 {'username': pull_request.author.user_id,
193 'reasons': [u'Default reviewer', u'Repository owner']},
194 )
194
195 owner_user_id = pull_request.target_repo.user.user_id
196 for spec_reviewer in reviewers[::]:
197 # default reviewer will be added who is an owner of the repo
198 # this get's overridden by a add owner to reviewers rule
199 if spec_reviewer['username'] == owner_user_id:
200 spec_reviewer['reasons'] = [u'Default reviewer', u'Repository owner']
201
195 202 assert sorted(actual_reviewers, key=lambda e: e['username']) \
196 203 == sorted(reviewers, key=lambda e: e['username'])
197 204
@@ -51,12 +51,12
51 51 """ Return json for default reviewers of a repository """
52 52
53 53 reasons = ['Default reviewer', 'Repository owner']
54 default = reviewer_as_json(
55 user=current_user, reasons=reasons, mandatory=False)
54 json_reviewers = [reviewer_as_json(
55 user=target_repo.user, reasons=reasons, mandatory=False, rules=None)]
56 56
57 57 return {
58 58 'api_ver': 'v1', # define version for later possible schema upgrade
59 'reviewers': [default],
59 'reviewers': json_reviewers,
60 60 'rules': {},
61 61 'rules_data': {},
62 62 }
Comments 0
You need to be logged in to leave comments. Login now