Skip to content

Commit 676d33f

Browse files
author
Matt Pearson
committed
Let 'append_hash' be set by an environment variable.
This brings back commit 5f38074 except it actually works this time. It also establishes a pattern of "if it's an env-var, overwrite _that_ when parsing args, then set the internal var using the env-var/defaults".
1 parent ebae8a2 commit 676d33f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

deploy.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ main() {
77
source .env
88
fi
99

10-
#append commit hash to the end of message by default
11-
append_hash=true
12-
1310
# Parse arg flags
11+
# If something is exposed as an environment variable, set/overwrite it
12+
# here. Otherwise, set/overwrite the internal variable instead.
1413
while : ; do
1514
if [[ $1 = "-v" || $1 = "--verbose" ]]; then
1615
verbose=true
@@ -22,7 +21,7 @@ main() {
2221
commit_message=$2
2322
shift 2
2423
elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then
25-
append_hash=false
24+
GIT_DEPLOY_APPEND_HASH=false
2625
shift
2726
elif [[ $1 = "-c" || $1 = "--config-file" ]]; then
2827
source "$2"
@@ -32,7 +31,10 @@ main() {
3231
fi
3332
done
3433

35-
# Set default options
34+
# Set internal option vars from the environment and arg flags. All internal
35+
# vars should be declared here, with sane defaults if applicable.
36+
37+
# Source directory & target branch.
3638
deploy_directory=${GIT_DEPLOY_DIR:-dist}
3739
deploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}
3840

@@ -42,7 +44,10 @@ main() {
4244

4345
#repository to deploy to. must be readable and writable.
4446
repo=${GIT_DEPLOY_REPO:-origin}
45-
47+
48+
#append commit hash to the end of message by default
49+
append_hash=${GIT_DEPLOY_APPEND_HASH:-true}
50+
4651
enable_expanded_output
4752

4853
if ! git diff --exit-code --quiet --cached; then

0 commit comments

Comments
 (0)