File: check_no_git_modifications.py

package info (click to toggle)
pydevd 3.3.0%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,892 kB
  • sloc: python: 77,508; cpp: 1,869; sh: 368; makefile: 50; ansic: 4
file content (100 lines) | stat: -rw-r--r-- 4,253 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import sys

expected_differences = set(
    line.strip()
    for line in r"""
--- a/_pydevd_bundle/pydevd_cython.c
+++ b/_pydevd_bundle/pydevd_cython.c
-  "_pydevd_bundle\\\\pydevd_cython.pyx",
-  "_pydevd_bundle\\\\pydevd_cython.pxd",
+  "_pydevd_bundle/pydevd_cython.pyx",
+  "_pydevd_bundle/pydevd_cython.pxd",

--- a/_pydevd_frame_eval/pydevd_frame_evaluator.c
+++ b/_pydevd_frame_eval/pydevd_frame_evaluator.c
-  "_pydevd_frame_eval\\\\pydevd_frame_evaluator.pyx",
+  "_pydevd_frame_eval/pydevd_frame_evaluator.pyx",
-  "_pydevd_bundle\\\\pydevd_cython.pxd",
+  "_pydevd_bundle/pydevd_cython.pxd",


-  "_pydevd_bundle/pydevd_cython.pyx",
-  "_pydevd_bundle/pydevd_cython.pxd",
+  "_pydevd_bundle\\\\pydevd_cython.pyx",
+  "_pydevd_bundle\\\\pydevd_cython.pxd",

-  "_pydevd_frame_eval/pydevd_frame_evaluator.pyx",
+  "_pydevd_frame_eval\\\\pydevd_frame_evaluator.pyx",
-  "_pydevd_bundle/pydevd_cython.pxd",
+  "_pydevd_bundle\\\\pydevd_cython.pxd",

--- a/_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c
+++ b/_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c
-  "_pydevd_sys_monitoring\\\\\\\\_pydevd_sys_monitoring_cython.pyx",
+  "_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx",
-  ".\\\\\\\\_pydevd_bundle\\\\\\\\pydevd_cython.pxd",
+  "./_pydevd_bundle/pydevd_cython.pxd",
-static const char __pyx_k_pydevd_sys_monitoring__pydevd_s[] = "_pydevd_sys_monitoring\\\\_pydevd_sys_monitoring_cython.pyx";
+static const char __pyx_k_pydevd_sys_monitoring__pydevd_s[] = "_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx";

-  "_pydevd_sys_monitoring\\\\_pydevd_sys_monitoring_cython.pyx",
-  ".\\\\\\\\_pydevd_bundle\\\\pydevd_cython.pxd",
-static const char __pyx_k_pydevd_sys_monitoring__pydevd_s[] = "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx";
-  ".\\\\\\\\_pydevd_bundle\\\\\\\\pydevd_cython.pxd",
-  ".\\\\_pydevd_bundle\\\\pydevd_cython.pxd",

-  "_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx",
+  "_pydevd_sys_monitoring\\\\\\\\_pydevd_sys_monitoring_cython.pyx",
-  "./_pydevd_bundle/pydevd_cython.pxd",
+  ".\\\\\\\\_pydevd_bundle\\\\\\\\pydevd_cython.pxd",
-static const char __pyx_k_pydevd_sys_monitoring__pydevd_s[] = "_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx";
+static const char __pyx_k_pydevd_sys_monitoring__pydevd_s[] = "_pydevd_sys_monitoring\\\\_pydevd_sys_monitoring_cython.pyx";

+  "_pydevd_sys_monitoring\\\\_pydevd_sys_monitoring_cython.pyx",
+  ".\\\\_pydevd_bundle\\\\pydevd_cython.pxd",
+static const char __pyx_k_pydevd_sys_monitoring__pydevd_s[] = "_pydevd_sys_monitoring\\_pydevd_sys_monitoring_cython.pyx";
""".splitlines()
    if line.strip()
)


def main():
    import subprocess

    process = subprocess.Popen("git status --porcelain".split(), stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
    output, _ = process.communicate()
    if output:
        if sys.version_info[0] > 2:
            output = output.decode("utf-8")

        files = set()
        for line in output.splitlines():
            filename = line[3:]
            files.add(filename.strip())

        files.discard(".travis_install_python_deps.sh")
        files.discard("miniconda.sh")
        files.discard("build_tools/check_no_git_modifications.py")
        found_unexpected = True
        if files:
            found_unexpected = False
            output = subprocess.check_output("git diff".split())
            for line in output.decode("utf-8").splitlines():
                if line.startswith("+") or line.startswith("-"):
                    if line.strip() not in expected_differences:
                        print("Found unexpected: %r" % (line,))
                        found_unexpected = True

        if files and found_unexpected:
            # If there are modifications, show a diff of the modifications and fail the script.
            # (we're mostly interested in modifications to the .c generated files by cython).
            print("Found modifications in git:\n%s " % (output,))
            print("Files: %s" % (files,))
            print("----------- diff -------------")
            subprocess.call("git diff".split())
            print("----------- end diff -------------")
            sys.exit(1)


if __name__ == "__main__":
    main()