meta:hooks:pre-push: Adjust to more concise style
Adjust the sample code from git to a more concise coding style, placing
{do,then} on the same line and using `[` instead of `test`.
This commit is contained in:
@@ -26,15 +26,12 @@ 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
|
while read local_ref local_oid remote_ref remote_oid; do
|
||||||
do
|
if [ "$local_oid" = "$zero" ]; then
|
||||||
if test "$local_oid" = "$zero"
|
|
||||||
then
|
|
||||||
# Handle delete
|
# Handle delete
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
if test "$remote_oid" = "$zero"
|
if [ "$remote_oid" = "$zero" ]; then
|
||||||
then
|
|
||||||
# New branch, examine all commits
|
# New branch, examine all commits
|
||||||
range="$local_oid"
|
range="$local_oid"
|
||||||
else
|
else
|
||||||
@@ -46,8 +43,7 @@ do
|
|||||||
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 test -n "$commits"
|
if [ -n "$commits" ]; then
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user