aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-08 17:43:18 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-08 17:43:18 -0400
commita76f5c19f80da7dd9416c6e29da7835d53b2d893 (patch)
tree1f412d305d2860502f536ccdcba90401227afb90 /b4/__init__.py
parentfe10a6b240621608de49dc4445a02b79c5611f15 (diff)
downloadb4-a76f5c19f80da7dd9416c6e29da7835d53b2d893.tar.gz
ez: chdir to toplevel when running get_maintainer
The scripts expect to be running from the toplevel directory, so make sure to switch back to git topdir before running get_maintainer.pl Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/__init__.py')
-rw-r--r--b4/__init__.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index e2ed881..3b8b9f3 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1903,10 +1903,21 @@ class LoreAttestorPatatt(LoreAttestor):
self.have_key = True
-def _run_command(cmdargs: List[str], stdin: Optional[bytes] = None) -> Tuple[int, bytes, bytes]:
+def _run_command(cmdargs: List[str], stdin: Optional[bytes] = None,
+ rundir: Optional[str] = None) -> Tuple[int, bytes, bytes]:
+ if rundir:
+ logger.debug('Changing dir to %s', rundir)
+ curdir = os.getcwd()
+ os.chdir(rundir)
+ else:
+ curdir = None
+
logger.debug('Running %s' % ' '.join(cmdargs))
sp = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
(output, error) = sp.communicate(input=stdin)
+ if curdir:
+ logger.debug('Changing back into %s', curdir)
+ os.chdir(curdir)
return sp.returncode, output, error