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

Method on_rename

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

Source from the content-addressed store, hash-verified

89 del self.func_commit[func_id]
90
91 def on_rename(self, diff, commit):
92 # when similarity is 100%, diff.a_blob and diff.b_blob are None, so don't use them
93 new_fname = diff.rename_to
94 old_fname = diff.rename_from
95 last_commit = commit.parents[0]
96 sha = commit.hexsha
97
98 if self.fname_filter(new_fname) or self.fname_filter(old_fname):
99 file_contents = get_contents(self.repo, last_commit, old_fname)
100 func_ids, func_ranges = self.func_extractor(file_contents, old_fname)
101 try:
102 modified_intervals = parse_patch(diff.diff.decode("utf-8"))
103 except UnicodeDecodeError:
104 print("UnicodeDecodeError Found in change_type {}".format(diff.change_type))
105 return -1
106 modified_func_ids = get_modified_func_ids(func_ranges, modified_intervals, func_ids)
107 for func_id in modified_func_ids:
108 if func_id in self.func_commit:
109 add_edge(self.G, sha, self.func_commit[func_id], func_id)
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

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