MCPcopy Create free account
hub / github.com/Persper/code-analytics / _analyze_commit

Method _analyze_commit

persper/analytics/analyzer.py:125–163  ·  view source on GitHub ↗
(self, commit, server_func)

Source from the content-addressed store, hash-verified

123 self.autosave('finished', 0, 1)
124
125 async def _analyze_commit(self, commit, server_func):
126 self._graph_server.register_commit(commit.hexsha,
127 commit.author.name,
128 commit.author.email,
129 commit.message)
130 diff_index = _diff_with_first_parent(commit)
131
132 for diff in diff_index:
133 old_fname, new_fname = _get_fnames(diff)
134 # Cases we don't handle
135 # 1. Both file names are None
136 if old_fname is None and new_fname is None:
137 print('WARNING: unknown change type encountered.')
138 continue
139
140 # 2. Either old_fname and new_fname doesn't pass filter
141 if ((old_fname and not self._graph_server.filter_file(old_fname)) or
142 (new_fname and not self._graph_server.filter_file(new_fname))):
143 continue
144
145 old_src = new_src = None
146
147 if old_fname:
148 old_src = get_contents(
149 self._ri.repo, commit.parents[0], old_fname)
150
151 if new_fname:
152 new_src = get_contents(self._ri.repo, commit, new_fname)
153
154 if old_src or new_src:
155 # todo (hezheng) store the status somewhere for reporting later
156 result = server_func(old_fname, old_src, new_fname, new_src, diff.diff)
157 if asyncio.iscoroutine(result):
158 result = await result
159 status = result
160
161 result = self._graph_server.end_commit(commit.hexsha)
162 if asyncio.iscoroutine(result):
163 result = await result
164
165 async def analyze_master_commit(self, commit):
166 await self._analyze_commit(commit, self._graph_server.update_graph)

Callers 2

analyze_master_commitMethod · 0.95
analyze_branch_commitMethod · 0.95

Calls 6

_diff_with_first_parentFunction · 0.90
get_contentsFunction · 0.90
_get_fnamesFunction · 0.70
register_commitMethod · 0.45
filter_fileMethod · 0.45
end_commitMethod · 0.45

Tested by

no test coverage detected