meta:hooks:pre-push: Refactor if-condition
This commit is contained in:
@@ -27,27 +27,24 @@ url="$2"
|
|||||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||||
|
|
||||||
while read local_ref local_oid remote_ref remote_oid; do
|
while read local_ref local_oid remote_ref remote_oid; do
|
||||||
if [ "$local_oid" = "$zero" ]; then
|
[ "$local_oid" != "$zero" ] || continue
|
||||||
# Handle delete
|
|
||||||
:
|
if [ "$remote_oid" = "$zero" ]; then
|
||||||
|
# New branch, examine all commits
|
||||||
|
range="$local_oid"
|
||||||
else
|
else
|
||||||
if [ "$remote_oid" = "$zero" ]; then
|
# Update to existing branch, examine new commits
|
||||||
# New branch, examine all commits
|
range="$remote_oid..$local_oid"
|
||||||
range="$local_oid"
|
fi
|
||||||
else
|
|
||||||
# Update to existing branch, examine new commits
|
|
||||||
range="$remote_oid..$local_oid"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for WIP or auto{squash,fixup} commit
|
# Check for WIP or auto{squash,fixup} commit
|
||||||
pattern='^(WIP|(fixup|squash)!)'
|
pattern='^(WIP|(fixup|squash)!)'
|
||||||
|
|
||||||
commits="$(git rev-list -E --oneline --grep "$pattern" "$range")"
|
commits="$(git rev-list -E --oneline --grep "$pattern" "$range")"
|
||||||
if [ -n "$commits" ]; then
|
if [ -n "$commits" ]; then
|
||||||
printf >&2 "$local_ref: Commits in progress:\n%s" "$commits"
|
printf >&2 "$local_ref: Commits in progress:\n%s" "$commits"
|
||||||
printf >&2 "Aborting push"
|
printf >&2 "Aborting push"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user