Skip to content

Commit fc94086

Browse files
committed
Add 'applyPatchDeps' config option
Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent b6ec9d6 commit fc94086

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

git_pw/config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010
LOG = logging.getLogger(__name__)
1111

1212

13+
def parse_boolean(value: str) -> bool:
14+
"""Parse a boolean config value.
15+
16+
Based on https://git-scm.com/docs/git-config#_values
17+
"""
18+
if value in ('yes', 'on', 'true', '1', ''):
19+
return True
20+
21+
if value in ('no', 'off', 'false', '0'):
22+
return False
23+
24+
LOG.error("'{}' is not a valid boolean value".format(value))
25+
return False
26+
27+
1328
class Config(object):
1429
def __init__(self) -> None:
1530
self._git_config: ty.Dict[str, str] = {}

git_pw/patch.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
)
4141

4242

43+
def _get_apply_patch_deps() -> bool:
44+
if CONF.applyPatchDeps is not None:
45+
return config.parse_boolean(CONF.applyPatchDeps)
46+
return True
47+
48+
4349
@click.command(
4450
name='apply',
4551
context_settings=dict(
@@ -55,10 +61,11 @@
5561
)
5662
@click.option(
5763
'--deps/--no-deps',
58-
default=True,
64+
default=_get_apply_patch_deps(),
5965
help=(
60-
'When applying the patch, include dependencies if '
61-
'available. Defaults to using the most recent series.'
66+
"When applying the patch, include series dependencies if available. "
67+
"Dependencies are retrieved from the most recent series by default. "
68+
"Defaults to the value of 'git config pw applyPatchDeps' else 'true'."
6269
),
6370
)
6471
@click.argument('args', nargs=-1, type=click.UNPROCESSED)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
The ``patch apply`` command will now respect the ``pw.applyPatchDeps``
5+
git config option. This can be a boolean value (one of: ``yes``, ``on``,
6+
``true``, ``1``, ``no``, ``off``, ``false``, ``0``).

0 commit comments

Comments
 (0)