mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge 132235cf82 into 8416413a0e
This commit is contained in:
commit
69176f75a3
1 changed files with 8 additions and 1 deletions
|
|
@ -114,6 +114,12 @@ def _rev_exists(rev: str) -> bool:
|
||||||
return not subprocess.call(('git', 'rev-list', '--quiet', rev))
|
return not subprocess.call(('git', 'rev-list', '--quiet', rev))
|
||||||
|
|
||||||
|
|
||||||
|
def _is_ancestor(ancestor: str, rev: str) -> bool:
|
||||||
|
return not subprocess.call(
|
||||||
|
('git', 'merge-base', '--is-ancestor', ancestor, rev),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _pre_push_ns(
|
def _pre_push_ns(
|
||||||
color: bool,
|
color: bool,
|
||||||
args: Sequence[str],
|
args: Sequence[str],
|
||||||
|
|
@ -127,7 +133,8 @@ def _pre_push_ns(
|
||||||
local_branch, local_sha, remote_branch, remote_sha = parts
|
local_branch, local_sha, remote_branch, remote_sha = parts
|
||||||
if local_sha == Z40:
|
if local_sha == Z40:
|
||||||
continue
|
continue
|
||||||
elif remote_sha != Z40 and _rev_exists(remote_sha):
|
elif remote_sha != Z40 and _rev_exists(remote_sha) \
|
||||||
|
and _is_ancestor(remote_sha, local_sha):
|
||||||
return _ns(
|
return _ns(
|
||||||
'pre-push', color,
|
'pre-push', color,
|
||||||
from_ref=remote_sha, to_ref=local_sha,
|
from_ref=remote_sha, to_ref=local_sha,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue