Commit ·
d584ff7
1
Parent(s): a1e1142
Update get_commits.py
Browse files40 unmodified lines41424344454445464748495051525354554849505152535455565758596057586160616262636465666740 unmodified lines
def get_diff(ex): commit_id = ex["commit"] repo = ex["unnested_repo_name"] repo = "https://www.github.com/" + repo + ".git" repos = list(set(ex["repos"].split(","))) old_file = ex["old_file"] new_file = ex["new_file"] for repo in repos:
# create a random directory to store the repo random_dir = random.randint(0, 1000000) run_in_shell("mkdir " + str(random_dir)) try: new_contents, old_contents = get_file_contents(commit_id, old_file, new_file, repo, cwd=str(random_dir)) except Exception as e: print("ERROR", commit_id, old_file, new_file, repo, str(random_dir), e) repo = "https://www.github.com/" + repo + ".git" # create a random directory to store the repo random_dir = random.randint(0, 1000000) run_in_shell("mkdir " + str(random_dir)) try: new_contents, old_contents = get_file_contents(commit_id, old_file, new_file, repo, cwd=str(random_dir)) except Exception as e: print("ERROR", commit_id, old_file, new_file, repo, str(random_dir), e) run_in_shell("rm -rf " + str(random_dir)) continue ex["new_contents"] = new_contents ex["old_contents"] = old_contents run_in_shell("rm -rf " + str(random_dir)) ex["new_contents"] = "" ex["old_contents"] = "" return ex ex["new_contents"] = new_contents ex["old_contents"] = old_contents run_in_shell("rm -rf " + str(random_dir)) # If no repo worked ex["new_contents"] = "" ex["old_contents"] = "" return ex
if __name__ == "__main__":get_commits.py+17-15