]> granicus.if.org Git - python/commitdiff
bpo-32256: Make patchcheck.py work for out-of-tree builds (GH-4760)
authorAlexey Izbyshev <izbyshev@ispras.ru>
Sat, 20 Oct 2018 00:49:41 +0000 (03:49 +0300)
committerVictor Stinner <vstinner@redhat.com>
Sat, 20 Oct 2018 00:49:41 +0000 (02:49 +0200)
Set SRCDIR as the current directory for git.

Tools/scripts/patchcheck.py

index a1253d1de5bb352f357af958d3632cb738dbb3b9..8a8480a0c22b37f6f9750759df539cadcab7f8f8 100755 (executable)
@@ -48,7 +48,9 @@ def get_git_branch():
     """Get the symbolic name for the current git branch"""
     cmd = "git rev-parse --abbrev-ref HEAD".split()
     try:
-        return subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
+        return subprocess.check_output(cmd,
+                                       stderr=subprocess.DEVNULL,
+                                       cwd=SRCDIR)
     except subprocess.CalledProcessError:
         return None
 
@@ -60,7 +62,9 @@ def get_git_upstream_remote():
     """
     cmd = "git remote get-url upstream".split()
     try:
-        subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
+        subprocess.check_output(cmd,
+                                stderr=subprocess.DEVNULL,
+                                cwd=SRCDIR)
     except subprocess.CalledProcessError:
         return "origin"
     return "upstream"
@@ -98,7 +102,9 @@ def changed_files(base_branch=None):
         else:
             cmd = 'git status --porcelain'
         filenames = []
-        with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st:
+        with subprocess.Popen(cmd.split(),
+                              stdout=subprocess.PIPE,
+                              cwd=SRCDIR) as st:
             for line in st.stdout:
                 line = line.decode().rstrip()
                 status_text, filename = line.split(maxsplit=1)