-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate.sh
33 lines (29 loc) · 987 Bytes
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# Console colors for better legibility.
COFF="\033[0m"
CINFO="\033[01;34m"
CSUCCESS="\033[0;32m"
CWARN="\033[0;33m"
CLINK="\033[0;35m"
CERROR="\033[0;31m"
# Script error handling.
handle_exit_code() {
ERROR_CODE="$?"
if [[ ${ERROR_CODE} != "0" ]]; then
echo -e " > ${CERROR}An error occurred somewhere. Exiting with code ${ERROR_CODE}.${COFF}"
exit ${ERROR_CODE}
else
echo -e " > ${CSUCCESS}Script execution completed!${COFF}"
exit ${ERROR_CODE}
fi
}
trap "handle_exit_code" EXIT
echo -e " > ${CINFO}Proceeding to pull latest update...${COFF}"
echo -e " > ${CINFO}Stashing local changes...${COFF}"
git stash
echo -e " > ${CINFO}Pulling latest commit from master branch...${COFF}"
git pull origin master
echo -e " > ${CINFO}Re-applying local changes...${COFF}"
git stash apply
echo -e " > ${CSUCCESS}Updates have been applied!${COFF}"
echo -e " > ${CWARN}Please make sure to check and fix the files that need 'merging' prior to running stack!${COFF}"