forked from pre-commit/pre-commit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-push-tmpl
More file actions
30 lines (29 loc) · 1.09 KB
/
pre-push-tmpl
File metadata and controls
30 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" != $z40 ]; then
if [ "$remote_sha" = $z40 ]; then
# First ancestor not found in remote
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
args="run --origin $local_sha --source $remote_sha"
fi
fi
done
if [ "$args" != "" ]; then
args="$args --hook-stage push"
else
# If args is empty, then an attempt to push on an empty
# changeset is being made. In this case, just exit cleanly
exit 0
fi