()
| 59 | |
| 60 | |
| 61 | def main(): |
| 62 | import subprocess |
| 63 | |
| 64 | process = subprocess.Popen("git status --porcelain".split(), stderr=subprocess.STDOUT, stdout=subprocess.PIPE) |
| 65 | output, _ = process.communicate() |
| 66 | if output: |
| 67 | if sys.version_info[0] > 2: |
| 68 | output = output.decode("utf-8") |
| 69 | |
| 70 | files = set() |
| 71 | for line in output.splitlines(): |
| 72 | filename = line[3:] |
| 73 | files.add(filename.strip()) |
| 74 | |
| 75 | files.discard(".travis_install_python_deps.sh") |
| 76 | files.discard("miniconda.sh") |
| 77 | files.discard("build_tools/check_no_git_modifications.py") |
| 78 | found_unexpected = True |
| 79 | if files: |
| 80 | found_unexpected = False |
| 81 | output = subprocess.check_output("git diff".split()) |
| 82 | for line in output.decode("utf-8").splitlines(): |
| 83 | if line.startswith("+") or line.startswith("-"): |
| 84 | if line.strip() not in expected_differences: |
| 85 | print("Found unexpected: %r" % (line,)) |
| 86 | found_unexpected = True |
| 87 | |
| 88 | if files and found_unexpected: |
| 89 | # If there are modifications, show a diff of the modifications and fail the script. |
| 90 | # (we're mostly interested in modifications to the .c generated files by cython). |
| 91 | print("Found modifications in git:\n%s " % (output,)) |
| 92 | print("Files: %s" % (files,)) |
| 93 | print("----------- diff -------------") |
| 94 | subprocess.call("git diff".split()) |
| 95 | print("----------- end diff -------------") |
| 96 | sys.exit(1) |
| 97 | |
| 98 | |
| 99 | if __name__ == "__main__": |
no test coverage detected