There was an error while loading. Please reload this page.
1 parent c0b1f2f commit 3181b46Copy full SHA for 3181b46
2 files changed
pre_commit/resources/hook-tmpl
@@ -123,14 +123,15 @@ def _pre_push(stdin):
123
elif remote_sha != Z40 and _rev_exists(remote_sha):
124
opts = ('--origin', local_sha, '--source', remote_sha)
125
else:
126
- # First ancestor not found in remote
127
- first_ancestor = subprocess.check_output((
128
- 'git', 'rev-list', '--max-count=1', '--topo-order',
129
- '--reverse', local_sha, '--not', '--remotes={}'.format(remote),
+ # ancestors not found in remote
+ ancestors = subprocess.check_output((
+ 'git', 'rev-list', local_sha, '--topo-order', '--reverse',
+ '--not', '--remotes={}'.format(remote),
130
)).decode().strip()
131
- if not first_ancestor:
+ if not ancestors:
132
continue
133
134
+ first_ancestor = ancestors.splitlines()[0]
135
cmd = ('git', 'rev-list', '--max-parents=0', local_sha)
136
roots = set(subprocess.check_output(cmd).decode().splitlines())
137
if first_ancestor in roots:
tests/commands/install_uninstall_test.py
@@ -527,11 +527,13 @@ def test_pre_push_integration_failing(tempdir_factory, store):
527
install(Runner(path, C.CONFIG_FILE), store, hook_type='pre-push')
528
# commit succeeds because pre-commit is only installed for pre-push
529
assert _get_commit_output(tempdir_factory)[0] == 0
530
+ assert _get_commit_output(tempdir_factory, touch_file='zzz')[0] == 0
531
532
retc, output = _get_push_output(tempdir_factory)
533
assert retc == 1
534
assert 'Failing hook' in output
535
assert 'Failed' in output
536
+ assert 'foo zzz' in output # both filenames should be printed
537
assert 'hookid: failing_hook' in output
538
539
0 commit comments