-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathloadRepos.py
53 lines (40 loc) · 1.56 KB
/
loadRepos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import subprocess
import os
# deltaspike and tapiji have very few commits labelled correctly
test_repo_dir = "gitRepos"
test_repos = [
("https://github.com/GNOME/valadoc.git", "valadoc"),
("https://github.com/GNOME/vala.git", "vala"),
("https://github.com/tapiji/tapiji.git", "tapiji"),
("https://git-wip-us.apache.org/repos/asf/deltaspike.git", "deltaspike"),
]
def check_missing_repos():
missing_repos = []
for git_url, repo in test_repos:
if (not os.path.isdir("{}/{}".format(test_repo_dir, repo))):
missing_repos.append((git_url, repo))
return missing_repos
def query_yes_no(question, yes_answer="Y", no_answer="n"):
prompt = "[{}/{}]".format(yes_answer, no_answer)
print("{} {}".format(question, prompt))
choice = input()
return choice.lower() == yes_answer.lower()
def clone_test_repos():
test_repos = check_missing_repos()
if (len(test_repos) == 0):
print("All test repos already cloned")
return True
question = "The following git repos need to be cloned to the \'gitRepos\' directory test the heuristic:\n"
for git_url, _ in test_repos:
question += "{}\n".format(git_url)
question += "Would you like to clone them now?"
can_clone_repos = query_yes_no(question)
if (not can_clone_repos):
return False
print("cloning...")
for git_url, repo in test_repos:
repo_path = "{}/{}".format(test_repo_dir, repo)
subprocess.run(["git", "clone", git_url, repo_path])
return True
if __name__ == "__main__":
clone_test_repos()