diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-08-17 15:13:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-17 15:13:01 (GMT) |
commit | d45cb040b9fcd74e8824d417bf789fcef4c9592c (patch) | |
tree | eb0054e94fb9370056d95b3fd343c4a5c860b023 /Tools/scripts/patchcheck.py | |
parent | 3cc46bb3ed8005b1d9b74bcb08a9c01b99e84c63 (diff) | |
download | cpython-d45cb040b9fcd74e8824d417bf789fcef4c9592c.zip cpython-d45cb040b9fcd74e8824d417bf789fcef4c9592c.tar.gz cpython-d45cb040b9fcd74e8824d417bf789fcef4c9592c.tar.bz2 |
[2.7] bpo-31221: patchcheck ignores external libraries (#3109) (#3118)
* bpo-31221: patchcheck ignores external libraries (#3109)
Tools/scripts/patchcheck.py now ignores changes in directories which
are copies of external libraries:
* Modules/_ctypes/libffi_msvc/
* Modules/_ctypes/libffi_osx/
* Modules/_decimal/libmpdec/
* Modules/expat/
* Modules/zlib/
Drop also support for Mercurial, since CPython migrated to Git.
Exclude also libmpdec
patchcheck: exclude also libffi_osx and libffi_msvc
(cherry picked from commit 4a347ce426fe7381885703d9074d7a6b3aeb2f2b)
* Exclude also Modules/_ctypes/libffi on Python 2.7
* Remove _decimal/libmpdec, not in Python 2.7
Diffstat (limited to 'Tools/scripts/patchcheck.py')
-rwxr-xr-x | Tools/scripts/patchcheck.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py index be46fe3..b69d540 100755 --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -10,8 +10,16 @@ import reindent import untabify +# Excluded directories which are copies of external libraries: +# don't check their coding style +EXCLUDE_DIRS = [os.path.join('Modules', '_ctypes', 'libffi'), + os.path.join('Modules', '_ctypes', 'libffi_osx'), + os.path.join('Modules', '_ctypes', 'libffi_msvc'), + os.path.join('Modules', 'expat'), + os.path.join('Modules', 'zlib')] SRCDIR = sysconfig.get_config_var('srcdir') + def n_files_str(count): """Return 'N file(s)' with the proper plurality on 'file'.""" return "{} file{}".format(count, "s" if count != 1 else "") @@ -102,7 +110,7 @@ def changed_files(base_branch=None): cmd += ' --rev qparent' st = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) try: - return [x.decode().rstrip() for x in st.stdout] + filenames = [x.decode().rstrip() for x in st.stdout] finally: st.stdout.close() elif os.path.exists(os.path.join(SRCDIR, '.git')): @@ -129,9 +137,19 @@ def changed_files(base_branch=None): filenames.append(filename) finally: st.stdout.close() - return filenames else: - sys.exit('need a checkout to get modified files') + sys.exit('need a Mercurial or git checkout to get modified files') + + filenames2 = [] + for filename in filenames: + # Normalize the path to be able to match using .startswith() + filename = os.path.normpath(filename) + if any(filename.startswith(path) for path in EXCLUDE_DIRS): + # Exclude the file + continue + filenames2.append(filename) + + return filenames2 def report_modified_files(file_paths): |