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

Method _analyzeCommit

persper/analytics/analyzer2.py:145–190  ·  view source on GitHub ↗

parentCommit can be None.

(self, commit: Union[Commit, str], parentCommit: Union[Commit, str],
                             seekingMode: CommitSeekingMode)

Source from the content-addressed store, hash-verified

143 analyzedCommits += 1
144
145 async def _analyzeCommit(self, commit: Union[Commit, str], parentCommit: Union[Commit, str],
146 seekingMode: CommitSeekingMode):
147 """
148 parentCommit can be None.
149 """
150 if type(commit) != Commit:
151 commit = self._repo.commit(commit)
152 self._observer.onBeforeCommit(self, commit, seekingMode)
153 result = self._graphServer.start_commit(commit.hexsha, seekingMode,
154 commit.author.name, commit.author.email, commit.message)
155 if asyncio.iscoroutine(result):
156 await result
157 diff_index = diff_with_commit(commit, parentCommit)
158
159 for diff in diff_index:
160 old_fname, new_fname = _get_fnames(diff)
161 # apply filter
162 # if a file comes into/goes from our view, we will set corresponding old_fname/new_fname to None,
163 # as if the file is introduced/removed in this commit.
164 # However, the diff will keep its original, no matter if the file has been filtered in/out.
165 if old_fname and not self._graphServer.filter_file(old_fname):
166 old_fname = None
167 if new_fname and not self._graphServer.filter_file(new_fname):
168 new_fname = None
169 if not old_fname and not new_fname:
170 # no modification
171 continue
172
173 old_src = new_src = None
174
175 if old_fname:
176 old_src = get_contents(self._repo, parentCommit, old_fname)
177
178 if new_fname:
179 new_src = get_contents(self._repo, commit, new_fname)
180
181 if old_src or new_src:
182 result = self._graphServer.update_graph(
183 old_fname, old_src, new_fname, new_src, diff.diff)
184 if asyncio.iscoroutine(result):
185 await result
186
187 result = self._graphServer.end_commit(commit.hexsha)
188 if asyncio.iscoroutine(result):
189 await result
190 self._observer.onAfterCommit(self, commit, seekingMode)
191
192
193def _get_fnames(diff: Diff):

Callers 1

analyzeMethod · 0.95

Calls 9

diff_with_commitFunction · 0.90
get_contentsFunction · 0.90
_get_fnamesFunction · 0.70
onBeforeCommitMethod · 0.45
start_commitMethod · 0.45
filter_fileMethod · 0.45
update_graphMethod · 0.45
end_commitMethod · 0.45
onAfterCommitMethod · 0.45

Tested by

no test coverage detected