Not aborting merge when there is a conflict
We want to upload the change even when there is a merge conflict and
fix the conflicts in Gerrit.
Test: TreeHugger
Change-Id: I04a0ad604b9222863d5087a1043306bc113e57d4
diff --git a/git_utils.py b/git_utils.py
index 5367e32..5fc9acf 100644
--- a/git_utils.py
+++ b/git_utils.py
@@ -151,8 +151,14 @@
except subprocess.CalledProcessError as err:
if hasattr(err, "output"):
print(err.output)
- _run(['git', 'merge', '--abort'], cwd=proj_path)
- raise
+ if not merge_conflict(proj_path):
+ raise
+
+
+def merge_conflict(proj_path: Path) -> bool:
+ """Checks if there was a merge conflict."""
+ out = _run(['git', 'ls-files', '--unmerged'], cwd=proj_path)
+ return bool(out)
def add_file(proj_path: Path, file_name: str) -> None: