diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-08-17 14:53:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-17 14:53:27 (GMT) |
commit | d23b1c4fd82a326e729027a791220d6011e097b4 (patch) | |
tree | 6d81c3edf16f40a30a7627422776af70ec12b4d9 | |
parent | fcecb0e365c35fb0e8410609d78881289bee7c26 (diff) | |
download | cpython-d23b1c4fd82a326e729027a791220d6011e097b4.zip cpython-d23b1c4fd82a326e729027a791220d6011e097b4.tar.gz cpython-d23b1c4fd82a326e729027a791220d6011e097b4.tar.bz2 |
[3.6] bpo-31221: patchcheck ignores external libraries (#3109) (#3116)
* 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 3.6
-rwxr-xr-x | Tools/scripts/patchcheck.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py index 436b277..5a1c94e 100755 --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -11,8 +11,17 @@ 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', '_decimal', 'libmpdec'), + 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 "") @@ -98,7 +107,7 @@ def changed_files(base_branch=None): if mq_patches_applied(): cmd += ' --rev qparent' with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st: - return [x.decode().rstrip() for x in st.stdout] + filenames = [x.decode().rstrip() for x in st.stdout] elif os.path.exists(os.path.join(SRCDIR, '.git')): # We just use an existence check here as: # directory = normal git checkout/clone @@ -120,10 +129,20 @@ def changed_files(base_branch=None): # file is renamed filename = filename.split(' -> ', 2)[1].strip() filenames.append(filename) - return filenames else: 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): count = len(file_paths) |