Skip to content

Commit 3c060fc

Browse files
authored
Check for latest commit before install.sh (#1186)
1 parent c258a1e commit 3c060fc

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fi
88
source "$(dirname $0)/install/_lib.sh" # does a `cd .../install/`, among other things
99

1010
source parse-cli.sh
11+
source check-latest-commit.sh
1112
source error-handling.sh
1213
source check-minimum-requirements.sh
1314
source create-docker-volumes.sh

install/check-latest-commit.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Checks if we are on latest commit from github if it is running from master branch
4+
if [[ -d "../.git" && "${SKIP_COMMIT_CHECK:-0}" != 1 ]]; then
5+
if [[ $(git branch | sed -n '/\* /s///p') == "master" ]]; then
6+
if [[ $(git rev-parse HEAD) != $(git ls-remote $(git rev-parse --abbrev-ref @{u} | sed 's/\// /g') | cut -f1) ]]; then
7+
echo "Seems like you are not using the latest commit from self-hosted repository. Please pull the latest changes and try again.";
8+
exit 1
9+
fi
10+
fi
11+
fi

install/parse-cli.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ EOF
1717

1818
SKIP_USER_PROMPT="${SKIP_USER_PROMPT:-}"
1919
MINIMIZE_DOWNTIME="${MINIMIZE_DOWNTIME:-}"
20+
SKIP_COMMIT_CHECK="${SKIP_COMMIT_CHECK:-}"
2021

2122
while (( $# )); do
2223
case "$1" in
2324
-h | --help) show_help; exit;;
2425
--no-user-prompt) SKIP_USER_PROMPT=1;;
2526
--minimize-downtime) MINIMIZE_DOWNTIME=1;;
27+
--skip-commit-check) SKIP_COMMIT_CHECK=1;;
2628
--) ;;
2729
*) echo "Unexpected argument: $1. Use --help for usage information."; exit 1;;
2830
esac

0 commit comments

Comments
 (0)