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

Method on_modify

persper/graphs/commit_graph.py:112–131  ·  view source on GitHub ↗
(self, diff, commit)

Source from the content-addressed store, hash-verified

110 self.func_commit[func_id] = sha
111
112 def on_modify(self, diff, commit):
113 assert diff.b_blob.path == diff.a_blob.path
114 fname = diff.b_blob.path
115 last_commit = commit.parents[0]
116 sha = commit.hexsha
117
118 if self.fname_filter(fname):
119 file_contents = get_contents(self.repo, last_commit, fname)
120 func_ids, func_ranges = self.func_extractor(file_contents, fname)
121 try:
122 modified_intervals = parse_patch(diff.diff.decode("utf-8"))
123 except UnicodeDecodeError:
124 print("UnicodeDecodeError Found in change_type {}".format(diff.change_type))
125 return -1
126 modified_func_ids = get_modified_func_ids(func_ranges, modified_intervals, func_ids)
127
128 for func_id in modified_func_ids:
129 if func_id in self.func_commit:
130 add_edge(self.G, sha, self.func_commit[func_id], func_id)
131 self.func_commit[func_id] = sha
132
133
134def draw_commit_graph(repo_path, language, output_path=None, num_commits=None):

Callers

nothing calls this directly

Calls 5

get_contentsFunction · 0.90
parse_patchFunction · 0.90
get_modified_func_idsFunction · 0.85
add_edgeFunction · 0.85
fname_filterMethod · 0.80

Tested by

no test coverage detected