Skip to content

Commit 3d49717

Browse files
committed
utils: Log subprocess calls
Makes 'git pw --debug ...' a little more useful. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 76b7909 commit 3d49717

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git_pw/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import csv
66
import io
7+
import logging
78
import os
89
import subprocess
910
import sys
@@ -12,6 +13,8 @@
1213
import click
1314
from tabulate import tabulate
1415

16+
LOG = logging.getLogger(__name__)
17+
1518

1619
def ensure_str(s: ty.Any) -> str:
1720
if s is None:
@@ -35,8 +38,13 @@ def git_config(value: str) -> str:
3538
Returns:
3639
Matching setting for ``key`` if available, else None.
3740
"""
41+
cmd = ['git', 'config', value]
42+
43+
LOG.debug('Fetching git config info for %s', value)
44+
LOG.debug('Running: %s', ' '.join(cmd))
45+
3846
try:
39-
output = subprocess.check_output(['git', 'config', value])
47+
output = subprocess.check_output(cmd)
4048
except subprocess.CalledProcessError:
4149
output = b''
4250

@@ -52,6 +60,9 @@ def git_am(mbox: str, args: ty.Tuple[str, ...]) -> None:
5260
cmd.append('-3')
5361
cmd.append(mbox)
5462

63+
LOG.debug('Applying patch at %s', mbox)
64+
LOG.debug('Running: %s', ' '.join(cmd))
65+
5566
try:
5667
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
5768
except subprocess.CalledProcessError as exc:

0 commit comments

Comments
 (0)