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
12 changes: 6 additions & 6 deletions cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def upstream(self):
"""
cmd = ["git", "remote", "get-url", "upstream"]
try:
self.run_cmd(cmd)
self.run_cmd(cmd, required_real_result=True)
except subprocess.CalledProcessError:
return "origin"
return "upstream"
Expand All @@ -170,7 +170,7 @@ def sorted_branches(self):
@property
def username(self):
cmd = ["git", "config", "--get", f"remote.{self.pr_remote}.url"]
result = self.run_cmd(cmd)
result = self.run_cmd(cmd, required_real_result=True)
# implicit ssh URIs use : to separate host from user, others just use /
username = result.replace(":", "/").split("/")[-2]
return username
Expand All @@ -188,9 +188,9 @@ def fetch_upstream(self):
self.run_cmd(cmd)
set_state(WORKFLOW_STATES.FETCHED_UPSTREAM)

def run_cmd(self, cmd):
def run_cmd(self, cmd, required_real_result=False):
assert not isinstance(cmd, str)
if self.dry_run:
if not required_real_result and self.dry_run:
click.echo(f" dry-run: {' '.join(cmd)}")
return
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
Expand Down Expand Up @@ -228,7 +228,7 @@ def get_commit_message(self, commit_sha):
"""
cmd = ["git", "show", "-s", "--format=%B", commit_sha]
try:
message = self.run_cmd(cmd).strip()
message = self.run_cmd(cmd, required_real_result=True).strip()
except subprocess.CalledProcessError as err:
click.echo(f"Error getting commit message for {commit_sha}")
click.echo(err.output)
Expand Down Expand Up @@ -584,7 +584,7 @@ def is_mirror(self) -> bool:

cmd = ["git", "config", "--local", "--get", "remote.origin.mirror"]
try:
out = self.run_cmd(cmd)
out = self.run_cmd(cmd, required_real_result=True)
except subprocess.CalledProcessError:
return False
return out.startswith("true")
Expand Down
2 changes: 1 addition & 1 deletion cherry_picker/test_cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def test_start_end_states(method_name, start_state, end_state, tmp_git_repo_dir)
cherry_picker.remember_previous_branch()
assert get_state() == WORKFLOW_STATES.UNSET

def _fetch(cmd):
def _fetch(cmd, *args, **kwargs):
assert get_state() == start_state

with mock.patch.object(cherry_picker, "run_cmd", _fetch):
Expand Down