mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Fix force-push without fetch
This commit is contained in:
parent
13c85f374b
commit
c294be513d
2 changed files with 28 additions and 4 deletions
|
|
@ -105,6 +105,10 @@ def _exe():
|
|||
)
|
||||
|
||||
|
||||
def _rev_exists(rev):
|
||||
return not subprocess.call(('git', 'rev-list', '--quiet', rev))
|
||||
|
||||
|
||||
def _pre_push(stdin):
|
||||
remote = sys.argv[1]
|
||||
|
||||
|
|
@ -113,7 +117,7 @@ def _pre_push(stdin):
|
|||
_, local_sha, _, remote_sha = line.split()
|
||||
if local_sha == Z40:
|
||||
continue
|
||||
elif remote_sha != Z40:
|
||||
elif remote_sha != Z40 and _rev_exists(remote_sha):
|
||||
opts = ('--origin', local_sha, '--source', remote_sha)
|
||||
else:
|
||||
# First ancestor not found in remote
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue