Muennighoff commited on
Commit
12cb6ed
1 Parent(s): c4d6e89

Update get_commits.py

Browse files
Files changed (1) hide show
  1. get_commits.py +1 -8
get_commits.py CHANGED
@@ -22,21 +22,14 @@ def run_in_shell(cmd: str, cwd=None, timeout=120):
22
  def get_file_contents(commit, old_file, new_file, repo, cwd=None):
23
 
24
  completed = run_in_shell("git init", cwd=cwd)
25
- print(completed)
26
  completed = run_in_shell("git remote add origin " + repo, cwd=cwd)
27
- print(completed)
28
  completed = run_in_shell("git fetch --depth 2 origin " + commit, cwd=cwd)
29
- print(completed)
30
  completed = run_in_shell("git checkout FETCH_HEAD -- " + new_file, cwd=cwd)
31
- print(completed)
32
-
33
  new_contents = run_in_shell("cat " + new_file, cwd=cwd).stdout.decode()
34
-
35
  completed = run_in_shell("git checkout FETCH_HEAD^ -- " + old_file, cwd=cwd)
36
- print(completed)
37
  if completed.returncode != 0:
38
  return (new_contents, "")
39
-
40
  old_contents = run_in_shell("cat " + old_file, cwd=cwd).stdout.decode()
41
  return (new_contents, old_contents)
42
 
 
22
  def get_file_contents(commit, old_file, new_file, repo, cwd=None):
23
 
24
  completed = run_in_shell("git init", cwd=cwd)
 
25
  completed = run_in_shell("git remote add origin " + repo, cwd=cwd)
 
26
  completed = run_in_shell("git fetch --depth 2 origin " + commit, cwd=cwd)
 
27
  completed = run_in_shell("git checkout FETCH_HEAD -- " + new_file, cwd=cwd)
 
 
28
  new_contents = run_in_shell("cat " + new_file, cwd=cwd).stdout.decode()
 
29
  completed = run_in_shell("git checkout FETCH_HEAD^ -- " + old_file, cwd=cwd)
30
+ # If there's only a new file, but no old file
31
  if completed.returncode != 0:
32
  return (new_contents, "")
 
33
  old_contents = run_in_shell("cat " + old_file, cwd=cwd).stdout.decode()
34
  return (new_contents, old_contents)
35