Skip to content

Commit 2c58f9b

Browse files
authored
Don't cd if we are in CPython directory (GH-12)
1 parent 98047ae commit 2c58f9b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

backport/tasks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ def setup_cpython_repo():
2424
f"git remote add upstream https://{os.environ.get('GH_AUTH')}:[email protected]/python/cpython.git".split())
2525
print("Finished setting up CPython Repo")
2626

27+
2728
@app.task
2829
def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by):
2930
"""Backport a commit into a branch."""
30-
print(os.chdir("./cpython"))
31+
if not util.is_cpython_repo():
32+
# cd to cpython if we're not already in it
33+
34+
os.chdir('./cpython')
3135
cp = cherry_picker.CherryPicker('origin', commit_hash, [branch])
3236
try:
3337
cp.backport()

backport/util.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
import os
3+
import subprocess
34

45
from gidgethub import sansio
56

@@ -26,4 +27,13 @@ def comment_on_pr(issue_number, message):
2627

2728

2829
def user_login(item):
29-
return item["user"]["login"]
30+
return item["user"]["login"]
31+
32+
33+
def is_cpython_repo():
34+
cmd = "git log -r 7f777ed95a19224294949e1b4ce56bbffcb1fe9f"
35+
try:
36+
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
37+
except subprocess.SubprocessError:
38+
return False
39+
return True

0 commit comments

Comments
 (0)