Skip to content

Commit 4e0f7ba

Browse files
committed
Add support for filtering by user/submitter ID
This was already sort of supported with the v1.1 API but now it's official. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 5aa68eb commit 4e0f7ba

File tree

7 files changed

+29
-19
lines changed

7 files changed

+29
-19
lines changed

git_pw/bundle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def _format_patch(patch):
114114

115115
@click.command(name='list')
116116
@click.option('--owner', metavar='OWNER', multiple=True,
117-
help='Show only bundles with these owners. Should be an email '
118-
'or name. Private bundles of other users will not be shown.')
117+
help='Show only bundles with these owners. Should be an email, '
118+
'name or ID. Private bundles of other users will not be shown.')
119119
@click.option('--limit', metavar='LIMIT', type=click.INT,
120120
help='Maximum number of bundles to show.')
121121
@click.option('--page', metavar='PAGE', type=click.INT,
@@ -138,7 +138,7 @@ def list_cmd(owner, limit, page, sort, name):
138138

139139
for own in owner:
140140
# we support server-side filtering by username (but not email) in 1.1
141-
if api.version() >= (1, 1) and '@' not in own:
141+
if (api.version() >= (1, 1) and '@' not in own) or own.isdigit():
142142
params.append(('owner', own))
143143
else:
144144
users = api.index('users', [('q', own)])

git_pw/patch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def update_cmd(patch_ids, commit_ref, state, delegate, archived):
185185
'are instance dependant.')
186186
@click.option('--submitter', metavar='SUBMITTER', multiple=True,
187187
help='Show only patches by these submitters. Should be an '
188-
'email or name.')
188+
'email, name or ID.')
189189
@click.option('--delegate', metavar='DELEGATE', multiple=True,
190190
help='Show only patches by these delegates. Should be an '
191191
'email or username.')
@@ -217,7 +217,7 @@ def list_cmd(state, submitter, delegate, archived, limit, page, sort, name):
217217

218218
for subm in submitter:
219219
# we support server-side filtering by email (but not name) in 1.1
220-
if api.version() >= (1, 1) and '@' in subm:
220+
if (api.version() >= (1, 1) and '@' in subm) or subm.isdigit():
221221
params.append(('submitter', subm))
222222
else:
223223
people = api.index('people', [('q', subm)])
@@ -232,7 +232,7 @@ def list_cmd(state, submitter, delegate, archived, limit, page, sort, name):
232232

233233
for delg in delegate:
234234
# we support server-side filtering by username (but not email) in 1.1
235-
if api.version() >= (1, 1) and '@' not in delg:
235+
if (api.version() >= (1, 1) and '@' not in delg) or delg.isdigit():
236236
params.append(('delegate', delg))
237237
else:
238238
users = api.index('users', [('q', delg)])

git_pw/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _format_submission(submission):
102102
@click.command(name='list')
103103
@click.option('--submitter', metavar='SUBMITTER', multiple=True,
104104
help='Show only series by these submitters. Should be an '
105-
'email or name.')
105+
'email, name or ID.')
106106
@click.option('--limit', metavar='LIMIT', type=click.INT,
107107
help='Maximum number of series to show.')
108108
@click.option('--page', metavar='PAGE', type=click.INT,
@@ -125,7 +125,7 @@ def list_cmd(submitter, limit, page, sort, name):
125125

126126
for subm in submitter:
127127
# we support server-side filtering by email (but not name) in 1.1
128-
if api.version() >= (1, 1) and '@' in subm:
128+
if (api.version() >= (1, 1) and '@' in subm) or subm.isdigit():
129129
params.append(('submitter', subm))
130130
else:
131131
people = api.index('people', [('q', subm)])
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
features:
3+
- |
4+
It is now possible to filter patches, bundles and series and the IDs of
5+
users that submitted or are delegated to the item in question. For
6+
example::
7+
8+
$ git pw patch list --submitter 1

tests/test_bundle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@ def test_list_with_filters(self, mock_index, mock_version):
220220

221221
runner = CLIRunner()
222222
result = runner.invoke(bundle.list_cmd, [
223-
'--owner', 'john.doe', '--limit', 1, '--page', 1,
223+
'--owner', 'john.doe', '--owner', '2', '--limit', 1, '--page', 1,
224224
'--sort', '-name', 'test'])
225225

226226
assert result.exit_code == 0, result
227227
calls = [
228228
mock.call('users', [('q', 'john.doe')]),
229229
mock.call('bundles', [
230-
('owner', 1), ('q', 'test'), ('page', 1), ('per_page', 1),
231-
('order', '-name')])]
230+
('owner', 1), ('owner', '2'), ('q', 'test'), ('page', 1),
231+
('per_page', 1), ('order', '-name')])]
232232

233233
mock_index.assert_has_calls(calls)
234234

tests/test_patch.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,19 @@ def test_list_with_filters(self, mock_index, mock_version):
321321
runner = CLIRunner()
322322
result = runner.invoke(patch.list_cmd, [
323323
'--state', 'new', '--submitter', '[email protected]',
324-
'--delegate', '[email protected]', '--archived',
324+
'--submitter', '2', '--delegate', '[email protected]',
325+
'--delegate', '2', '--archived',
325326
'--limit', 1, '--page', 1, '--sort', '-name', 'test'])
326327

327328
assert result.exit_code == 0, result
328329
calls = [
329330
mock.call('people', [('q', '[email protected]')]),
330331
mock.call('users', [('q', '[email protected]')]),
331332
mock.call('patches', [
332-
('state', 'new'), ('submitter', 1), ('delegate', 1),
333-
('q', 'test'), ('archived', 'true'), ('page', 1),
334-
('per_page', 1), ('order', '-name')])]
333+
('state', 'new'), ('submitter', 1), ('submitter', '2'),
334+
('delegate', 1), ('delegate', '2'), ('q', 'test'),
335+
('archived', 'true'), ('page', 1), ('per_page', 1),
336+
('order', '-name')])]
335337

336338
mock_index.assert_has_calls(calls)
337339

tests/test_series.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ def test_list_with_filters(self, mock_index, mock_version):
175175

176176
runner = CLIRunner()
177177
result = runner.invoke(series.list_cmd, [
178-
'--submitter', '[email protected]', '--limit', 1, '--page', 1,
179-
'--sort', '-name', 'test'])
178+
'--submitter', '[email protected]', '--submitter', '2',
179+
'--limit', 1, '--page', 1, '--sort', '-name', 'test'])
180180

181181
assert result.exit_code == 0, result
182182
calls = [
183183
mock.call('people', [('q', '[email protected]')]),
184184
mock.call('series', [
185-
('submitter', 1), ('q', 'test'), ('page', 1), ('per_page', 1),
186-
('order', '-name')])]
185+
('submitter', 1), ('submitter', '2'), ('q', 'test'),
186+
('page', 1), ('per_page', 1), ('order', '-name')])]
187187

188188
mock_index.assert_has_calls(calls)
189189

0 commit comments

Comments
 (0)