Skip to content

Commit aabc24f

Browse files
committed
Added script to make a backup of all repos referenced by GitHub org intReposInfo.json file
1 parent 3f50744 commit aabc24f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

scripts/clone_everything.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /usr/bin/env python3
2+
3+
import pathlib
4+
import subprocess
5+
from timeit import default_timer as timer
6+
7+
import requests
8+
9+
INPUT_FILE = "https://raw.githubusercontent.com/LLNL/llnl.github.io/main/visualize/github-data/intReposInfo.json"
10+
11+
12+
def main():
13+
repo_info = requests.get(INPUT_FILE).json()["data"]
14+
15+
BACKUP_PATH = "github_backup"
16+
pathlib.Path(BACKUP_PATH).mkdir(parents=True, exist_ok=True)
17+
18+
start = timer()
19+
20+
for slug, data in repo_info.items():
21+
url = data["url"]
22+
clone_path = f"{BACKUP_PATH}/{slug}"
23+
if pathlib.Path(clone_path).exists():
24+
print(f"... updating: {url}")
25+
subprocess.run(["time", "git", "fetch"], cwd=clone_path)
26+
else:
27+
print(f"... cloning: {url}")
28+
subprocess.run(["time", "git", "clone", "--mirror", url, clone_path])
29+
if not pathlib.Path(clone_path).exists():
30+
print("Something went wrong with the clone, don't try to lfs fetch...")
31+
continue
32+
subprocess.run(["time", "git", "lfs", "fetch", "--all"], cwd=clone_path)
33+
34+
end = timer()
35+
36+
print(end - start) # Time in seconds, e.g. 5.38091952400282
37+
38+
39+
if __name__ == "__main__":
40+
main()

0 commit comments

Comments
 (0)