Skip to content

Commit aa95bfb

Browse files
Alexey Izbyshevvstinner
authored andcommitted
bpo-32256: Make patchcheck.py work for out-of-tree builds (GH-4760)
Set SRCDIR as the current directory for git.
1 parent d5b4f1b commit aa95bfb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Tools/scripts/patchcheck.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def get_git_branch():
4848
"""Get the symbolic name for the current git branch"""
4949
cmd = "git rev-parse --abbrev-ref HEAD".split()
5050
try:
51-
return subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
51+
return subprocess.check_output(cmd,
52+
stderr=subprocess.DEVNULL,
53+
cwd=SRCDIR)
5254
except subprocess.CalledProcessError:
5355
return None
5456

@@ -60,7 +62,9 @@ def get_git_upstream_remote():
6062
"""
6163
cmd = "git remote get-url upstream".split()
6264
try:
63-
subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
65+
subprocess.check_output(cmd,
66+
stderr=subprocess.DEVNULL,
67+
cwd=SRCDIR)
6468
except subprocess.CalledProcessError:
6569
return "origin"
6670
return "upstream"
@@ -98,7 +102,9 @@ def changed_files(base_branch=None):
98102
else:
99103
cmd = 'git status --porcelain'
100104
filenames = []
101-
with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st:
105+
with subprocess.Popen(cmd.split(),
106+
stdout=subprocess.PIPE,
107+
cwd=SRCDIR) as st:
102108
for line in st.stdout:
103109
line = line.decode().rstrip()
104110
status_text, filename = line.split(maxsplit=1)

0 commit comments

Comments
 (0)