Skip to content
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

Handle git execute error #123

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 12 additions & 3 deletions cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
pass


class GitCommandFailedException(Exception):
pass


class CherryPicker:
ALLOWED_STATES = WORKFLOW_STATES.BACKPORT_PAUSED, WORKFLOW_STATES.UNSET
"""The list of states expected at the start of the app."""
Expand Down Expand Up @@ -794,9 +798,8 @@

click.echo("\U0001F40D \U0001F352 \u26CF")

chosen_config_path, config = load_config(config_path)

try:
chosen_config_path, config = load_config(config_path)
cherry_picker = CherryPicker(
pr_remote,
commit_sha1,
Expand All @@ -808,6 +811,9 @@
config=config,
chosen_config_path=chosen_config_path,
)
except GitCommandFailedException as exc:
click.echo(exc)
sys.exit(-1)
except InvalidRepoException:
click.echo(f"You're not inside a {config['repo']} repo right now! \U0001F645")
sys.exit(-1)
Expand Down Expand Up @@ -994,7 +1000,10 @@
def get_sha1_from(commitish):
"""Turn 'commitish' into its sha1 hash."""
cmd = ["git", "rev-parse", commitish]
return subprocess.check_output(cmd).strip().decode("utf-8")
proc = subprocess.run(cmd, capture_output=True)
if proc.returncode != 0:
raise GitCommandFailedException(proc.stderr.strip().decode("utf-8"))

Check warning on line 1005 in cherry_picker/cherry_picker.py

View check run for this annotation

Codecov / codecov/patch

cherry_picker/cherry_picker.py#L1005

Added line #L1005 was not covered by tests
return proc.stdout.strip().decode("utf-8")


def reset_stored_config_ref():
Expand Down
Loading