Skip to content

Commit eeaa18e

Browse files
committed
Update style
1 parent 87fd4ab commit eeaa18e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tools/git/hooks/pre-push

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#!/usr/bin/env bash
22
#
3-
# A git hook called by "git push" after it has checked the remote status, but before anything has been pushed.
4-
#
5-
# If this script exits with a non-zero status, nothing will be pushed.
3+
# A git hook called by `git push` after it has checked the remote status, but before anything has been pushed. If this script exits with a non-zero status, nothing will be pushed.
64
#
75
# This hook is called with the following parameters:
86
#
9-
# $1 - name of the remote to which the push is being done
10-
# $2 - URL to which the push is being done
7+
# * `$1` - name of the remote to which the push is being done
8+
# * `$2` - URL to which the push is being done
119
#
1210
# If pushing without using a named remote, these arguments will be equal.
1311
#
14-
# Information about the commits which are being pushed is supplied as lines to stdin in the form:
12+
# Information about the commits which are being pushed is supplied as lines to `stdin` in the form:
1513
#
14+
# ``` text
1615
# <local ref> <local sha1> <remote ref> <remote sha1>
17-
#
16+
# ```
17+
1818

1919
# VARIABLES #
2020

@@ -25,7 +25,7 @@ url="$2"
2525
export GIT_HOOK_TEST='make test'
2626

2727
# Determine the current branch:
28-
export GIT_CURRENT_BRANCH=`git name-rev --name-only HEAD`
28+
export GIT_CURRENT_BRANCH="$(git name-rev --name-only HEAD)"
2929

3030

3131
# FUNCTIONS #
@@ -45,8 +45,8 @@ cleanup() {
4545

4646
# Checks if commits exist to push, as `git push` will execute regardless of whether commits exist to push or not.
4747
has_commits() {
48-
echo 'Checking for commits to push...'
49-
local commits=`git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline`
48+
echo 'Checking for commits to push...' >&2
49+
local commits="$(git log origin/${GIT_CURRENT_BRANCH}..${GIT_CURRENT_BRANCH} --oneline)"
5050
if [[ -z "$commits" ]]; then
5151
return 1
5252
fi
@@ -55,10 +55,10 @@ has_commits() {
5555

5656
# Runs tests.
5757
run_tests() {
58-
echo 'Running tests...'
59-
$GIT_HOOK_TEST
58+
echo 'Running tests...' >&2
59+
"$(${GIT_HOOK_TEST})"
6060
if [[ "$?" -ne 0 ]]; then
61-
echo "$GIT_HOOK_TEST failed." >&2
61+
echo "${GIT_HOOK_TEST} failed." >&2
6262
return 1
6363
fi
6464
echo 'Tests passed.' >&2

0 commit comments

Comments
 (0)