Skip to content

Commit

Permalink
Don't cd if we are in CPython directory (GH-12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariatta authored Sep 6, 2017
1 parent 98047ae commit 2c58f9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backport/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ def setup_cpython_repo():
f"git remote add upstream https://{os.environ.get('GH_AUTH')}:x-oauth-basic@github.com/python/cpython.git".split())
print("Finished setting up CPython Repo")


@app.task
def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by):
"""Backport a commit into a branch."""
print(os.chdir("./cpython"))
if not util.is_cpython_repo():
# cd to cpython if we're not already in it

os.chdir('./cpython')
cp = cherry_picker.CherryPicker('origin', commit_hash, [branch])
try:
cp.backport()
Expand Down
12 changes: 11 additions & 1 deletion backport/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests
import os
import subprocess

from gidgethub import sansio

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


def user_login(item):
return item["user"]["login"]
return item["user"]["login"]


def is_cpython_repo():
cmd = "git log -r 7f777ed95a19224294949e1b4ce56bbffcb1fe9f"
try:
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
except subprocess.SubprocessError:
return False
return True

0 comments on commit 2c58f9b

Please sign in to comment.