Skip to content

Commit

Permalink
legit sync can be configured to do ff-only merge.
Browse files Browse the repository at this point in the history
`legit sync` will only do fast-forward merges
if both of the following conditions met:

1. `legit.smartMerge` is **false**
2. `pull.ff` is **only**
  • Loading branch information
weakish committed Jul 20, 2017
1 parent 252b1eb commit 4782928
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions legit/scm.py
Expand Up @@ -138,12 +138,15 @@ def smart_merge(branch, allow_rebase=True):
else:
verb = 'merge'

try:
return repo.git.execute([git, verb, branch])
except GitCommandError as why:
log = repo.git.execute([git, verb, '--abort'])
abort('Merge failed. Reverting.',
log='{0}\n{1}'.format(why, log), type='merge')
if git_pull_ff_only():
return repo.git.execute([git, verb, '--ff-only', branch])
else:
try:
return repo.git.execute([git, verb, branch])
except GitCommandError as why:
log = repo.git.execute([git, verb, '--abort'])
abort('Merge failed. Reverting.',
log='{0}\n{1}'.format(why, log), type='merge')


def git_pull_rebase():
Expand All @@ -154,6 +157,17 @@ def git_pull_rebase():
return False


def git_pull_ff_only():
reader = repo.config_reader()
if reader.has_option('pull', 'ff'):
if reader.getboolean('pull', 'ff') == "only":
return True
else:
return False
else:
return False


def push(branch=None):

repo_check(require_remote=True)
Expand Down

0 comments on commit 4782928

Please sign in to comment.