Skip to content

Commit

Permalink
[util/cmdgen.py] Ensure working directory is repo root
Browse files Browse the repository at this point in the history
Commands may contain paths, which are relative to the root of the
repository.  In order to make command invocation independent of the
current working directory, we set `cwd` of `subprocess.run` to the root
of the repository.

Signed-off-by: Andreas Kurth <[email protected]>
  • Loading branch information
andreaskurth authored and matutem committed Nov 2, 2024
1 parent f591bea commit 0acbd56
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion util/cmdgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def cmdgen_rewrite_md(filepath: Path, dry_run: bool, update: bool) -> bool:
continue

# Run the found-command in a subshell
res = subprocess.run(cmd, shell=True, capture_output=True)
res = subprocess.run(cmd, shell=True, capture_output=True,
cwd=REPO_ROOT)
if res.stderr:
logger.info(
f"{rel_path}:L{match_start_linum}: `{cmd}` "
Expand Down

0 comments on commit 0acbd56

Please sign in to comment.