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')
|
||||
|
||||
while read local_ref local_oid remote_ref remote_oid; do
|
||||
if [ "$local_oid" = "$zero" ]; then
|
||||
# Handle delete
|
||||
:
|
||||
[ "$local_oid" != "$zero" ] || continue
|
||||
|
||||
if [ "$remote_oid" = "$zero" ]; then
|
||||
# New branch, examine all commits
|
||||
range="$local_oid"
|
||||
else
|
||||
if [ "$remote_oid" = "$zero" ]; then
|
||||
# New branch, examine all commits
|
||||
range="$local_oid"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_oid..$local_oid"
|
||||
fi
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_oid..$local_oid"
|
||||
fi
|
||||
|
||||
# Check for WIP or auto{squash,fixup} commit
|
||||
pattern='^(WIP|(fixup|squash)!)'
|
||||
# Check for WIP or auto{squash,fixup} commit
|
||||
pattern='^(WIP|(fixup|squash)!)'
|
||||
|
||||
commits="$(git rev-list -E --oneline --grep "$pattern" "$range")"
|
||||
if [ -n "$commits" ]; then
|
||||
printf >&2 "$local_ref: Commits in progress:\n%s" "$commits"
|
||||
printf >&2 "Aborting push"
|
||||
exit 1
|
||||
fi
|
||||
commits="$(git rev-list -E --oneline --grep "$pattern" "$range")"
|
||||
if [ -n "$commits" ]; then
|
||||
printf >&2 "$local_ref: Commits in progress:\n%s" "$commits"
|
||||
printf >&2 "Aborting push"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user