From 5b49b3837d71647763d13a940440b656e94be886 Mon Sep 17 00:00:00 2001 From: andreparames Date: Fri, 16 Feb 2018 16:43:09 +0100 Subject: [PATCH] Allow the possibility to specify merge options Merge options can come in useful (ex.: when there are conflicts between two PRs). This commit adds the code for them, initially just supporting the 'strategy-option'. --- git_aggregator/repo.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/git_aggregator/repo.py b/git_aggregator/repo.py index d6797dc..f166757 100644 --- a/git_aggregator/repo.py +++ b/git_aggregator/repo.py @@ -16,6 +16,7 @@ from ._compat import console_to_str FETCH_DEFAULTS = ("depth", "shallow-since", "shallow-exclude") +MERGE_DEFAULTS = ("strategy-option",) logger = logging.getLogger(__name__) @@ -217,6 +218,15 @@ def _fetch_options(self, merge): cmd += ("--%s" % option, str(value)) return cmd + def _merge_options(self, merge): + """Get the merge options from the given merge dict.""" + cmd = tuple() + for option in MERGE_DEFAULTS: + value = merge.get(option, self.defaults.get(option)) + if value: + cmd += ("--%s" % option, str(value)) + return cmd + def _reset_to(self, remote, ref): logger.info('Reset branch to %s %s', remote, ref) rtype, sha = self.query_remote_ref(remote, ref) @@ -249,7 +259,9 @@ def _merge(self, merge): cmd += ('--no-edit',) if logger.getEffectiveLevel() != logging.DEBUG: cmd += ('--quiet',) - cmd += self._fetch_options(merge) + (merge["remote"], merge["ref"]) + cmd += (self._fetch_options(merge) + + self._merge_options(merge) + + (merge["remote"], merge["ref"])) self.log_call(cmd) def _get_remotes(self):