MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / get_conflicted_files

Function get_conflicted_files

pre_commit/git.py:114–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112
113
114def get_conflicted_files() -> set[str]:
115 logger.info('Checking merge-conflict files only.')
116 # Need to get the conflicted files from the MERGE_MSG because they could
117 # have resolved the conflict by choosing one side or the other
118 with open(os.path.join(get_git_dir('.'), 'MERGE_MSG'), 'rb') as f:
119 merge_msg = f.read()
120 merge_conflict_filenames = parse_merge_msg_for_conflicts(merge_msg)
121
122 # This will get the rest of the changes made after the merge.
123 # If they resolved the merge conflict by choosing a mesh of both sides
124 # this will also include the conflicted files
125 tree_hash = cmd_output('git', 'write-tree')[1].strip()
126 merge_diff_filenames = zsplit(
127 cmd_output(
128 'git', 'diff', '--name-only', '--no-ext-diff', '-z',
129 '-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--',
130 )[1],
131 )
132 return set(merge_conflict_filenames) | set(merge_diff_filenames)
133
134
135def get_staged_files(cwd: str | None = None) -> list[str]:

Callers

nothing calls this directly

Calls 4

cmd_outputFunction · 0.90
get_git_dirFunction · 0.85
zsplitFunction · 0.85

Tested by

no test coverage detected