FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix pre-push after rebase by taliastocks · Pull Request #3427 · pre-commit/pre-commit · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 8 additions & 1 deletion pre_commit/commands/hook_impl.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def _rev_exists(rev: str) -> bool:
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(
color: bool,
args: Sequence[str],
Expand All @@ -126,7 +132,8 @@ def _pre_push_ns(
local_branch, local_sha, remote_branch, remote_sha = parts
if local_sha == Z40:
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(
'pre-push', color,
from_ref=remote_sha, to_ref=local_sha,
Expand Down

Back | FazBrowse Home | New Git URL