Skip to content
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ python:
- "3.8"
- "3.7"
- "3.6"
- "nightly" # currently, it's 3.10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 3.10a5 which doesn't have functionality that new pip expects from 3.10 so it fails miserably.


matrix:
allow_failures:
- python: "nightly"
dist: focal

install:
- python -m pip install --upgrade flit pip
- python -m pip install --upgrade flit
- python -m pip install --upgrade pip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's easier to tell if one of those fails which one it was.

- flit install

script:
Expand Down
30 changes: 17 additions & 13 deletions cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def upstream(self):
"""
cmd = ["git", "remote", "get-url", "upstream"]
try:
subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
self.run_cmd(cmd)
except subprocess.CalledProcessError:
return "origin"
return "upstream"
Expand All @@ -153,8 +153,7 @@ def sorted_branches(self):
@property
def username(self):
cmd = ["git", "config", "--get", f"remote.{self.pr_remote}.url"]
raw_result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
result = raw_result.decode("utf-8")
result = self.run_cmd(cmd)
# implicit ssh URIs use : to separate host from user, others just use /
username = result.replace(":", "/").split("/")[-2]
return username
Expand All @@ -178,7 +177,7 @@ def run_cmd(self, cmd):
click.echo(f" dry-run: {' '.join(cmd)}")
return
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
click.echo(output.decode("utf-8"))
return output.decode("utf-8")

def checkout_branch(self, branch_name):
""" git checkout -b <branch_name> """
Expand Down Expand Up @@ -206,8 +205,12 @@ def get_commit_message(self, commit_sha):
replace #<PRID> with GH-<PRID>
"""
cmd = ["git", "show", "-s", "--format=%B", commit_sha]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
message = output.strip().decode("utf-8")
try:
message = self.run_cmd(cmd).strip()
except subprocess.CalledProcessError as err:
click.echo(f"Error getting commit message for {commit_sha}")
click.echo(err.output)
raise CherryPickException(f"Error getting commit message for {commit_sha}")
if self.config["fix_commit_msg"]:
return message.replace("#", "GH-")
else:
Expand All @@ -228,13 +231,13 @@ def status(self):
:return:
"""
cmd = ["git", "status"]
self.run_cmd(cmd)
return self.run_cmd(cmd)

def cherry_pick(self):
""" git cherry-pick -x <commit_sha1> """
cmd = ["git", "cherry-pick", "-x", self.commit_sha1]
try:
self.run_cmd(cmd)
click.echo(self.run_cmd(cmd))
except subprocess.CalledProcessError as err:
click.echo(f"Error cherry-pick {self.commit_sha1}.")
click.echo(err.output)
Expand Down Expand Up @@ -271,7 +274,7 @@ def amend_commit_message(self, cherry_pick_branch):
else:
cmd = ["git", "commit", "--amend", "-m", updated_commit_message]
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
self.run_cmd(cmd)
except subprocess.CalledProcessError as cpe:
click.echo("Failed to amend the commit message \u2639")
click.echo(cpe.output)
Expand All @@ -285,8 +288,9 @@ def push_to_remote(self, base_branch, head_branch, commit_message=""):
try:
self.run_cmd(cmd)
set_state(WORKFLOW_STATES.PUSHED_TO_REMOTE)
except subprocess.CalledProcessError:
except subprocess.CalledProcessError as cpe:
click.echo(f"Failed to push to {self.pr_remote} \u2639")
click.echo(cpe.output)
set_state(WORKFLOW_STATES.PUSHING_TO_REMOTE_FAILED)
else:
gh_auth = os.getenv("GH_AUTH")
Expand Down Expand Up @@ -338,7 +342,7 @@ def open_pr(self, url):

def delete_branch(self, branch):
cmd = ["git", "branch", "-D", branch]
self.run_cmd(cmd)
return self.run_cmd(cmd)

def cleanup_branch(self, branch):
"""Remove the temporary backport branch.
Expand Down Expand Up @@ -414,7 +418,7 @@ def abort_cherry_pick(self):
cmd = ["git", "cherry-pick", "--abort"]
try:
set_state(WORKFLOW_STATES.ABORTING)
self.run_cmd(cmd)
click.echo(self.run_cmd(cmd))
set_state(WORKFLOW_STATES.ABORTED)
except subprocess.CalledProcessError as cpe:
click.echo(cpe.output)
Expand Down Expand Up @@ -466,7 +470,7 @@ def continue_cherry_pick(self):
updated_commit_message,
"--allow-empty",
]
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
self.run_cmd(cmd)

self.push_to_remote(base, cherry_pick_branch)

Expand Down