mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #486 from philipgian/master
Improve pre-push fileset for a new remote branch
This commit is contained in:
commit
b514e757d5
1 changed files with 13 additions and 3 deletions
|
|
@ -2,9 +2,19 @@ z40=0000000000000000000000000000000000000000
|
||||||
while read local_ref local_sha remote_ref remote_sha
|
while read local_ref local_sha remote_ref remote_sha
|
||||||
do
|
do
|
||||||
if [ "$local_sha" != $z40 ]; then
|
if [ "$local_sha" != $z40 ]; then
|
||||||
if [ "$remote_sha" = $z40 ];
|
if [ "$remote_sha" = $z40 ]; then
|
||||||
then
|
# First ancestor not found in remote
|
||||||
args="run --all-files"
|
first_ancestor=$(git rev-list --topo-order --reverse "$local_sha" --not --remotes="$1" | head -n 1)
|
||||||
|
if [ -n "$first_ancestor" ]; then
|
||||||
|
# Check that the ancestor has at least one parent
|
||||||
|
git rev-list --max-parents=0 "$local_sha" | grep "$first_ancestor" > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
args="run --all-files"
|
||||||
|
else
|
||||||
|
source=$(git rev-parse "$first_ancestor"^)
|
||||||
|
args="run --origin $local_sha --source $source"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
args="run --origin $local_sha --source $remote_sha"
|
args="run --origin $local_sha --source $remote_sha"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue