Skip to content

cherry_picker now can only be run from CPython repo #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cherry_picker/cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,10 @@ def cherry_pick_cli(dry_run, pr_remote, abort, status, push,
commit_sha1, branches):

click.echo("\U0001F40D \U0001F352 \u26CF")
current_dir = os.getcwd()
pyconfig_path = os.path.join(current_dir, 'pyconfig.h.in')

if not os.path.exists(pyconfig_path):
os.chdir(os.path.join(current_dir, 'cpython'))
if not is_cpython_repo():
click.echo("You're not inside a CPython repo right now! 🙅")
sys.exit(-1)

if dry_run:
click.echo("Dry run requested, listing expected command sequence")
Expand Down Expand Up @@ -320,5 +319,14 @@ def get_full_sha_from_short(short_sha):
return full_sha


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


if __name__ == '__main__':
cherry_pick_cli()
17 changes: 16 additions & 1 deletion cherry_picker/cherry_picker/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from .cherry_picker import get_base_branch, get_current_branch, \
get_full_sha_from_short, CherryPicker
get_full_sha_from_short, is_cpython_repo, CherryPicker


def test_get_base_branch():
Expand Down Expand Up @@ -97,3 +97,18 @@ def test_get_updated_commit_message(subprocess_check_output, os_path_exists):
branches)
assert cp.get_commit_message('22a594a0047d7706537ff2ac676cdc0f1dcb329c') \
== 'bpo-123: Fix Spam Module (GH-113)'

@mock.patch('subprocess.check_output')
def test_is_cpython_repo(subprocess_check_output):
subprocess_check_output.return_value = """commit 7f777ed95a19224294949e1b4ce56bbffcb1fe9f
Author: Guido van Rossum <[email protected]>
Date: Thu Aug 9 14:25:15 1990 +0000

Initial revision

"""
assert is_cpython_repo() == True

def test_is_not_cpython_repo():
assert is_cpython_repo() == False