Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the possibility to specify merge options #20

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion git_aggregator/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down