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

Method _analyze_commit

persper/graphs/analyzer.py:121–156  ·  view source on GitHub ↗
(self, commit, ccg_func)

Source from the content-addressed store, hash-verified

119 self.autosave('finished', 0, 1)
120
121 def _analyze_commit(self, commit, ccg_func):
122 sha = commit.hexsha
123 self.ordered_shas.append(sha)
124 self.history[sha] = {}
125 self.id_map[sha] = {}
126 diff_index = _diff_with_first_parent(commit)
127
128 for diff in diff_index:
129 old_fname, new_fname = _get_fnames(diff)
130 # Cases we don't handle
131 # 1. Both file names are None
132 if old_fname is None and new_fname is None:
133 print('WARNING: unknown change type encountered.')
134 continue
135
136 # 2. Either old_fname and new_fname doesn't pass filter
137 if ((old_fname and not self.graph_server.filter_file(old_fname)) or
138 (new_fname and not self.graph_server.filter_file(new_fname))):
139 continue
140
141 old_src = new_src = None
142
143 if old_fname:
144 old_src = get_contents(
145 self.ri.repo, commit.parents[0], old_fname)
146
147 if new_fname:
148 new_src = get_contents(self.ri.repo, commit, new_fname)
149
150 if old_src or new_src:
151 # Delegate actual work to graph_server
152 id_to_lines, id_map = ccg_func(
153 old_fname, old_src, new_fname, new_src, diff.diff)
154
155 self.history[sha].update(id_to_lines)
156 self.id_map[sha].update(id_map)
157
158 def analyze_master_commit(self, commit):
159 self._analyze_commit(commit, self.graph_server.update_graph)

Callers 2

analyze_master_commitMethod · 0.95
analyze_branch_commitMethod · 0.95

Calls 4

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

Tested by

no test coverage detected