<s> from pygit2 import GIT_DIFF_REVERSE <EOL> def detect_renamed ( repository , ref , path = None ) : <EOL> """<STR_LIT>""" <EOL> commit = repository . revparse_single ( ref ) <EOL> parents = commit . parents <EOL> if len ( parents ) == <NUM_LIT:0> : <EOL> opt = GIT_DIFF_REVERSE <EOL> diff = commit . tree . diff ( flags = opt , empty_tree = True ) <EOL> else : <EOL> parent = parents [ <NUM_LIT:0> ] <EOL> diff = parent . tree . diff ( commit . tree ) <EOL> diff . find_similar ( ) <EOL> result = dict ( ( d . new_file_path , d . old_file_path ) <EOL> for d in diff if d . status == "<STR_LIT:R>" ) <EOL> return result </s>
