Skip to content

Commit 1130fb8

Browse files
committed
[Git Commit]: at 2018-09-29 15:12:18-05:00
1 parent 78b16ac commit 1130fb8

File tree

1 file changed

+42
-21
lines changed

1 file changed

+42
-21
lines changed

git-build.sh

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,62 @@ __with_extension="${__base}.sh"
2323
handle_exit_code() {
2424
ERROR_CODE="$?"
2525
if [ "${ERROR_CODE}" = "0" ]; then
26-
printf -- '\033[32m SUCCESS: %s \033[0m\n' "${deepMsg:-${__with_extension}}";
27-
printf -- '\033[32m Finished without errors. \033[0m\n'
28-
printf -- '\033[32m Exiting with status code 0.\033[0m\n';
26+
printf -- '\033[32m [SUCCESS]: %s \033[0m\n' "${deepMsg:-${__with_extension}}"
27+
printf -- '\033[32m [FINISHED] without errors. \033[0m\n'
28+
printf -- '\033[32m [EXIT] with status code %s.\033[0m\n' "${ERROR_CODE}"
29+
exit ${ERROR_CODE}
30+
fi
31+
if [ "${ERROR_CODE}" = "1" ]; then
32+
printf -- '\033[31m [ERROR CODE %s]: ERROR_CODE %s primary to echo call failed.\033[0m\n' ${ERROR_CODE} ${ERROR_CODE}
33+
printf -- '\033[31m [EXIT] with status code %s.\033[0m\n' "${ERROR_CODE}"
34+
exit ${ERROR_CODE}
35+
fi
36+
if [ "${ERROR_CODE}" = "2" ]; then
37+
printf -- '\033[31m [ERROR CODE %s]: ERROR_CODE %s primary to echo call failed.\033[0m\n' ${ERROR_CODE} ${ERROR_CODE}
38+
printf -- '\033[31m [EXIT] with status code %s.\033[0m\n' "${ERROR_CODE}"
2939
exit ${ERROR_CODE}
3040
fi
3141
# ...
3242
if [ "${ERROR_CODE}" != "0" ]; then
33-
printf -- 'Exiting with status code 2.\n'
43+
printf -- '\033[31m [ERROR CODE %s]: ERROR_CODE %s is not defined yet.\033[0m\n' ${ERROR_CODE} ${ERROR_CODE}
44+
printf -- '\033[31m [EXIT] with status code %s.\033[0m\n' "${ERROR_CODE}"
3445
exit ${ERROR_CODE}
3546
fi
36-
printf -- "an error occurred. cleaning up now... "
37-
# ... cleanup code ...
38-
printf -- "DONE.\\nExiting with error code %s.\\n", "${ERROR_CODE}"
47+
printf -- '\033[31m [ERROR] occurred. Cleaning up now...\033[0m\n'
48+
### Cleanup
49+
printf -- '\033[33m [CLEAN]: Cleaning exit properly.\n\033[31m [EXIT] with error code %s.\n' "${ERROR_CODE}"
3950
exit "${ERROR_CODE}"
4051
}
4152
trap "handle_exit_code" EXIT
4253

54+
if [ -d "${GIT_RAW_TEST}" ]; then
55+
echo "[Testing]: ${GIT_RAW_TEST} exists."
56+
curl "${GIT_RAW_TEST}" && echo || exit 2
57+
printf -- '\033[32m [SUCCESS]: %s \033[0m\n' ${GIT_RAW_TEST}
58+
sleep 1
59+
else
60+
echo "[GIT_RAW_TEST]: Not Setup! ${GIT_RAW_TEST}"
61+
git clone "${ROOT_PATH}/${GIT_REPOSITORY}" && echo || exit 2
62+
printf -- '\033[32m [SUCCESS]: %s \033[0m\n' "${GIT_LOCAL_PATH}"
63+
sleep 1
64+
fi
4365
if [ $# -eq 1 ]; then
44-
"${GIT_COMMIT_MSG}"="$1"
66+
${GIT_COMMIT_MSG}="$1"
4567
${GIT_REPOSITORY:-'https://github.com/DeepInThought/vscode-shell-snippets.git'}
46-
echo "[Git Comment]: ${GIT-COMMIT}"
68+
echo "[Git Comment]: ${GIT-GIT_COMMIT_MSG}"
4769
echo "[Git Repository]: ${GIT_REPOSITORY}"
48-
if [ -d "${GIT_RAW_TEST}" ]; then
49-
echo "[Testing]: ${GIT_RAW_TEST} exists."
50-
curl "${GIT_RAW_TEST}" && echo
51-
sleep 1
52-
else
53-
echo "[GIT_RAW_TEST]: Not Setup! ${GIT_RAW_TEST}"
54-
git clone "${ROOT_PATH}/${GIT_REPOSITORY}"
55-
sleep 1
56-
fi
70+
git commit -m ${GIT_COMMIT_MSG} || printf -- '\033[32m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE} && exit 1
71+
printf -- '\033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
72+
else
73+
${GIT_COMMIT_MSG:-"echo [Git Commit]: on $(date --rfc-3339=seconds)"}
74+
git commit -m ${GIT_COMMIT_MSG} || printf -- '\033[32m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE} && exit 1
75+
printf -- '\033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
76+
fi
77+
if [ $# -eq 2 ]; then
5778
echo "[Git Comment]: ${GIT-COMMIT}"
58-
echo "Commit on: $(date --rfc-3339=seconds)"
59-
git commit -m ${GIT_COMMIT_MSG} || printf -- '\033[31m ERROR: git commit -m ${GIT_COMMIT_MSG} failed! \033[0m\n' && exit 1
60-
printf -- '\033[32m Finished without errors. \033[0m\n'
79+
echo "Commit on: $(date --rfc-3339=seconds)"
80+
git commit -m ${GIT_COMMIT_MSG} || printf -- '\033[32m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE} && exit 1
81+
printf -- '\033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
6182
else
6283
echo "Commit on: $(date --rfc-3339=seconds)" && echo "${GIT_COMMIT_MSG}"
6384
fi

0 commit comments

Comments
 (0)