-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloneProjects.py
More file actions
46 lines (35 loc) · 1.64 KB
/
cloneProjects.py
File metadata and controls
46 lines (35 loc) · 1.64 KB
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
import os
import time
from dotenv import load_dotenv
load_dotenv("filePaths.env")
INPUT_FILE = os.getenv('PROJECTS-VERSIONS-FILE')
OUTPUT_FOLDER = os.getenv('CLONED-PROJECTS-FOLDER')
PAGINATION_OFFSET = os.getenv('VERSIONS-FILE-OFFSET', False)
PAGINATION_LIMIT = os.getenv('VERSIONS-FILE-LIMIT', False)
SLEEP_SECONDS = 10
SLEEP_INTERVAL = 10
reposCount = 0
os.system("mkdir -p " + OUTPUT_FOLDER)
with open(INPUT_FILE) as file:
for line in file:
repoSplitBySlash = line.split("/")
ownerName = repoSplitBySlash[3]
repoName = repoSplitBySlash[4]
version = ((repoSplitBySlash[5])[1:])
version = version.replace("\n", "")
version = version.replace(" ", "")
outputRepoName = OUTPUT_FOLDER + "/" + str(reposCount) + "-" + ownerName + "-" + repoName + "-" + version
repoURL = ((line.split(";"))[0])[:-1]
print("[" + str(reposCount) + "] Cloning " + outputRepoName)
if os.path.exists(outputRepoName[:-1]) == True:
print("INFO: The directory alread exists. No actions performed.")
elif (version == "None"):
os.system("git clone " + repoURL + " " + outputRepoName)
print("SUCCESS: Clone was executed without version.")
else:
os.system("git clone -b " + version + " --single-branch " + repoURL + " " + outputRepoName)
print("SUCCESS: Clone was executed with version.")
reposCount += 1
if (reposCount % SLEEP_INTERVAL == 0):
print("INFO: Sleeping for " + str(SLEEP_SECONDS) + " seconds...")
time.sleep(SLEEP_SECONDS)