Skip to content

Commit f912ed6

Browse files
committed
[conflict-mediator] Add alternative command
1 parent a628605 commit f912ed6

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

conflict_mediator/download.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ def run_command(command: List[str], verbose: bool) -> Optional[str]:
2525
exit(1)
2626

2727

28+
def run_command_no_exit(command: List[str], verbose: bool) -> Optional[str]:
29+
try:
30+
result = subprocess.run(
31+
command,
32+
capture_output=True,
33+
text=True,
34+
check=True,
35+
)
36+
if verbose:
37+
print(result.stdout)
38+
return result.stdout
39+
except subprocess.CalledProcessError as e:
40+
if verbose:
41+
print(e.stderr)
42+
return None
43+
44+
2845
def create_or_update_file(
2946
filepath: str | pathlib.Path, contents: Optional[str] = None
3047
) -> None:
@@ -59,7 +76,4 @@ def setup(verbose: bool = False):
5976

6077
run_command(["git", "checkout", "main"], verbose)
6178
run_command(["git", "merge", "A", "--no-edit"], verbose)
62-
try:
63-
run_command(["git", "merge", "B", "--no-edit"], verbose)
64-
except BaseException:
65-
print("Fix the merge conflict in script.py!")
79+
run_command_no_exit(["git", "merge", "B", "--no-edit"], verbose)

0 commit comments

Comments
 (0)