From 48c28dd09b109f3ac384e65bdd9376fe035c8a89 Mon Sep 17 00:00:00 2001 From: Tommaso Date: Thu, 14 Sep 2023 16:29:36 +0200 Subject: [PATCH] Fix merge function message parsing --- doltcli/dolt.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doltcli/dolt.py b/doltcli/dolt.py index 73b01e8..c593fd9 100644 --- a/doltcli/dolt.py +++ b/doltcli/dolt.py @@ -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}: @@ -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, @@ -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")