Check for latest commit before install.sh (#1186)

This commit is contained in:
Amin Vakil 2021-12-07 00:11:13 +03:30 committed by GitHub
parent c258a1e939
commit 3c060fc8d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@ fi
source "$(dirname $0)/install/_lib.sh" # does a `cd .../install/`, among other things source "$(dirname $0)/install/_lib.sh" # does a `cd .../install/`, among other things
source parse-cli.sh source parse-cli.sh
source check-latest-commit.sh
source error-handling.sh source error-handling.sh
source check-minimum-requirements.sh source check-minimum-requirements.sh
source create-docker-volumes.sh source create-docker-volumes.sh

View File

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

View File

@ -17,12 +17,14 @@ EOF
SKIP_USER_PROMPT="${SKIP_USER_PROMPT:-}" SKIP_USER_PROMPT="${SKIP_USER_PROMPT:-}"
MINIMIZE_DOWNTIME="${MINIMIZE_DOWNTIME:-}" MINIMIZE_DOWNTIME="${MINIMIZE_DOWNTIME:-}"
SKIP_COMMIT_CHECK="${SKIP_COMMIT_CHECK:-}"
while (( $# )); do while (( $# )); do
case "$1" in case "$1" in
-h | --help) show_help; exit;; -h | --help) show_help; exit;;
--no-user-prompt) SKIP_USER_PROMPT=1;; --no-user-prompt) SKIP_USER_PROMPT=1;;
--minimize-downtime) MINIMIZE_DOWNTIME=1;; --minimize-downtime) MINIMIZE_DOWNTIME=1;;
--skip-commit-check) SKIP_COMMIT_CHECK=1;;
--) ;; --) ;;
*) echo "Unexpected argument: $1. Use --help for usage information."; exit 1;; *) echo "Unexpected argument: $1. Use --help for usage information."; exit 1;;
esac esac