Commit ·
12cb6ed
1
Parent(s): c4d6e89
Update get_commits.py
Browse files21 unmodified lines22232425262728293031323334353637383940414221 unmodified linesdef get_file_contents(commit, old_file, new_file, repo, cwd=None):completed = run_in_shell("git init", cwd=cwd)print(completed)completed = run_in_shell("git remote add origin " + repo, cwd=cwd)print(completed)completed = run_in_shell("git fetch --depth 2 origin " + commit, cwd=cwd)print(completed)completed = run_in_shell("git checkout FETCH_HEAD -- " + new_file, cwd=cwd)print(completed)new_contents = run_in_shell("cat " + new_file, cwd=cwd).stdout.decode()completed = run_in_shell("git checkout FETCH_HEAD^ -- " + old_file, cwd=cwd)print(completed)if completed.returncode != 0:return (new_contents, "")old_contents = run_in_shell("cat " + old_file, cwd=cwd).stdout.decode()return (new_contents, old_contents)21 unmodified lines222324252627282930313233343521 unmodified linesdef get_file_contents(commit, old_file, new_file, repo, cwd=None):completed = run_in_shell("git init", cwd=cwd)completed = run_in_shell("git remote add origin " + repo, cwd=cwd)completed = run_in_shell("git fetch --depth 2 origin " + commit, cwd=cwd)completed = run_in_shell("git checkout FETCH_HEAD -- " + new_file, cwd=cwd)new_contents = run_in_shell("cat " + new_file, cwd=cwd).stdout.decode()completed = run_in_shell("git checkout FETCH_HEAD^ -- " + old_file, cwd=cwd)# If there's only a new file, but no old fileif completed.returncode != 0:return (new_contents, "")old_contents = run_in_shell("cat " + old_file, cwd=cwd).stdout.decode()return (new_contents, old_contents)
get_commits.py+1-8