Skip to content

Commit

Permalink
Fix merge function message parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
tommasogritti committed Sep 14, 2023
1 parent 296fb54 commit 48c28dd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions doltcli/dolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,15 @@ def merge(self, branch: str, message: Optional[str] = None, squash: bool = False

args.append(branch)
output = self.execute(args, **kwargs).split("\n")
merge_conflict_pos = 2

if len(output) == 3 and "Fast-forward" in output[1]:
# TODO: this was and remains a hack, we need to parse the output properly
if len(output) > 1 and "Fast-forward" in output[0]:
logger.info(f"Completed fast-forward merge of {branch} into {current_branch.name}")
return

if len(output) == 5 and output[merge_conflict_pos].startswith("CONFLICT"):
# TODO: this was and remains a hack, we need to parse the output properly
merge_conflict_pos = 8
if len(output) > 1 and output[merge_conflict_pos].startswith("CONFLICT"):
logger.warning(
f"""
The following merge conflict occurred merging {branch} to {current_branch.name}:
Expand All @@ -511,10 +513,13 @@ def merge(self, branch: str, message: Optional[str] = None, squash: bool = False
logger.info(message)
status = self.status()

commit_required = False
for table in list(status.added_tables.keys()) + list(status.modified_tables.keys()):
self.add(table)
commit_required = True

self.commit(message)
if commit_required:
self.commit(message)

def sql(
self,
Expand Down Expand Up @@ -1219,7 +1224,6 @@ def _config_helper(
get: bool = False,
unset: bool = False,
) -> Dict[str, str]:

switch_count = [el for el in [add, list, get, unset] if el]
if len(switch_count) != 1:
raise ValueError("Exactly one of add, list, get, unset must be True")
Expand Down

0 comments on commit 48c28dd

Please sign in to comment.