Muennighoff commited on
Commit
d584ff7
·
1 Parent(s): a1e1142

Update get_commits.py

Browse files
Files changed (1) hide show
  1. get_commits.py +17 -15
get_commits.py CHANGED
@@ -41,25 +41,27 @@ def get_file_contents(commit, old_file, new_file, repo, cwd=None):
41
 
42
  def get_diff(ex):
43
  commit_id = ex["commit"]
44
- repo = ex["unnested_repo_name"]
45
- repo = "https://www.github.com/" + repo + ".git"
46
  old_file = ex["old_file"]
47
  new_file = ex["new_file"]
48
-
49
- # create a random directory to store the repo
50
- random_dir = random.randint(0, 1000000)
51
- run_in_shell("mkdir " + str(random_dir))
52
- try:
53
- new_contents, old_contents = get_file_contents(commit_id, old_file, new_file, repo, cwd=str(random_dir))
54
- except Exception as e:
55
- print("ERROR", commit_id, old_file, new_file, repo, str(random_dir), e)
 
 
 
 
 
56
  run_in_shell("rm -rf " + str(random_dir))
57
- ex["new_contents"] = ""
58
- ex["old_contents"] = ""
59
  return ex
60
- ex["new_contents"] = new_contents
61
- ex["old_contents"] = old_contents
62
- run_in_shell("rm -rf " + str(random_dir))
63
  return ex
64
 
65
  if __name__ == "__main__":
 
41
 
42
  def get_diff(ex):
43
  commit_id = ex["commit"]
44
+ repos = list(set(ex["repos"].split(",")))
 
45
  old_file = ex["old_file"]
46
  new_file = ex["new_file"]
47
+ for repo in repos:
48
+ repo = "https://www.github.com/" + repo + ".git"
49
+ # create a random directory to store the repo
50
+ random_dir = random.randint(0, 1000000)
51
+ run_in_shell("mkdir " + str(random_dir))
52
+ try:
53
+ new_contents, old_contents = get_file_contents(commit_id, old_file, new_file, repo, cwd=str(random_dir))
54
+ except Exception as e:
55
+ print("ERROR", commit_id, old_file, new_file, repo, str(random_dir), e)
56
+ run_in_shell("rm -rf " + str(random_dir))
57
+ continue
58
+ ex["new_contents"] = new_contents
59
+ ex["old_contents"] = old_contents
60
  run_in_shell("rm -rf " + str(random_dir))
 
 
61
  return ex
62
+ # If no repo worked
63
+ ex["new_contents"] = ""
64
+ ex["old_contents"] = ""
65
  return ex
66
 
67
  if __name__ == "__main__":