Skip to content

Commit dbe0d8e

Browse files
authored
Don't clone CPython repo if it already exists (GH-33)
1 parent 375d8d1 commit dbe0d8e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

backport/tasks.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
CELERY_RESULT_BACKEND=os.environ['REDIS_URL'])
1313

1414

15-
1615
@app.task(rate_limit="1/m")
1716
def setup_cpython_repo():
18-
subprocess.check_output(
19-
f"git clone https://{os.environ.get('GH_AUTH')}:[email protected]/miss-islington/cpython.git".split())
20-
subprocess.check_output("git config --global user.email '[email protected]'".split())
21-
subprocess.check_output(["git", "config", "--global", "user.name", "'Miss Islington (bot)'"])
22-
os.chdir('./cpython')
23-
subprocess.check_output(
24-
f"git remote add upstream https://{os.environ.get('GH_AUTH')}:[email protected]/python/cpython.git".split())
25-
print("Finished setting up CPython Repo")
17+
if "cpython" not in os.listdir('.'):
18+
subprocess.check_output(
19+
f"git clone https://{os.environ.get('GH_AUTH')}:[email protected]/miss-islington/cpython.git".split())
20+
subprocess.check_output("git config --global user.email '[email protected]'".split())
21+
subprocess.check_output(["git", "config", "--global", "user.name", "'Miss Islington (bot)'"])
22+
os.chdir('./cpython')
23+
subprocess.check_output(
24+
f"git remote add upstream https://{os.environ.get('GH_AUTH')}:[email protected]/python/cpython.git".split())
25+
print("Finished setting up CPython Repo")
26+
else:
27+
print("cpython directory already exists")
2628

2729

2830
@app.task(rate_limit="1/m")

0 commit comments

Comments
 (0)