MCPcopy Index your code
hub / github.com/python/cpython / changed_files

Function changed_files

Tools/patchcheck/patchcheck.py:139–170  ·  view source on GitHub ↗

Get the list of changed or added files from git.

(base_branch=None)

Source from the content-addressed store, hash-verified

137@status("Getting the list of files that have been added/changed",
138 info=lambda x: n_files_str(len(x)))
139def changed_files(base_branch=None):
140 """Get the list of changed or added files from git."""
141 if os.path.exists(os.path.join(SRCDIR, '.git')):
142 # We just use an existence check here as:
143 # directory = normal git checkout/clone
144 # file = git worktree directory
145 if base_branch:
146 cmd = 'git diff --name-status ' + base_branch
147 else:
148 cmd = 'git status --porcelain'
149 filenames = []
150 with subprocess.Popen(cmd.split(),
151 stdout=subprocess.PIPE,
152 cwd=SRCDIR) as st:
153 git_file_status, _ = st.communicate()
154 if st.returncode != 0:
155 sys.exit(f'error running {cmd}')
156 for line in git_file_status.splitlines():
157 line = line.decode().rstrip()
158 status_text, filename = line.split(maxsplit=1)
159 status = set(status_text)
160 # modified, added or unmerged files
161 if not status.intersection('MAU'):
162 continue
163 if ' -> ' in filename:
164 # file is renamed
165 filename = filename.split(' -> ', 2)[1].strip()
166 filenames.append(filename)
167 else:
168 sys.exit('need a git checkout to get modified files')
169
170 return list(map(os.path.normpath, filenames))
171
172
173@status("Docs modified", modal=True)

Callers 1

mainFunction · 0.85

Calls 13

setFunction · 0.85
listClass · 0.85
existsMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
communicateMethod · 0.45
exitMethod · 0.45
splitlinesMethod · 0.45
rstripMethod · 0.45
decodeMethod · 0.45
intersectionMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…