|
10 | 10 | import click
|
11 | 11 |
|
12 | 12 | from git_pw import api
|
| 13 | +from git_pw import config |
13 | 14 | from git_pw import utils
|
14 | 15 |
|
| 16 | +CONF = config.CONF |
15 | 17 | LOG = logging.getLogger(__name__)
|
16 | 18 |
|
17 |
| -_list_headers = ('ID', 'Date', 'Name', 'Submitter', 'State', 'Archived', |
18 |
| - 'Delegate') |
19 |
| -_sort_fields = ('id', '-id', 'name', '-name', 'date', '-date') |
| 19 | +_list_headers = ( |
| 20 | + 'ID', 'Date', 'Name', 'Submitter', 'State', 'Archived', 'Delegate') |
| 21 | +_sort_fields = ( |
| 22 | + 'id', '-id', 'name', '-name', 'date', '-date') |
| 23 | +_default_states = ( |
| 24 | + 'new', 'under-review', 'accepted', 'rejected', 'rfc', 'not-applicable', |
| 25 | + 'changes-requested', 'awaiting-upstream', 'superseded', 'deferred') |
20 | 26 |
|
21 | 27 |
|
22 | 28 | @click.command(name='apply', context_settings=dict(
|
@@ -135,13 +141,18 @@ def show_cmd(fmt, patch_id):
|
135 | 141 | _show_patch(patch, fmt)
|
136 | 142 |
|
137 | 143 |
|
| 144 | +def _get_states(): |
| 145 | + return CONF.states.split(',') if CONF.states else _default_states |
| 146 | + |
| 147 | + |
138 | 148 | @click.command(name='update')
|
139 | 149 | @click.argument('patch_ids', type=click.INT, nargs=-1, required=True)
|
140 | 150 | @click.option('--commit-ref', metavar='COMMIT_REF',
|
141 | 151 | help='Set the patch commit reference hash')
|
142 |
| -@click.option('--state', metavar='STATE', |
143 |
| - help='Set the patch state. Should be a slugified representation ' |
144 |
| - 'of a state. The available states are instance dependant.') |
| 152 | +@click.option('--state', metavar='STATE', type=click.Choice(_get_states()), |
| 153 | + help="Set the patch state. Should be a slugified representation " |
| 154 | + "of a state. The available states are instance dependant and " |
| 155 | + "can be configured using 'git config pw.states'.") |
145 | 156 | @click.option('--delegate', metavar='DELEGATE',
|
146 | 157 | help='Set the patch delegate. Should be unique user identifier: '
|
147 | 158 | 'either a username or a user\'s email address.')
|
|
0 commit comments