diff --git a/scripts/bootstrapit_update.sh b/scripts/bootstrapit_update.sh index 3edf62b..69e13b8 100644 --- a/scripts/bootstrapit_update.sh +++ b/scripts/bootstrapit_update.sh @@ -3,8 +3,16 @@ set -Ee -o pipefail; shopt -s extglob nocasematch; -md5sum=$(which md5sum || which md5) - +if [[ -f ${PROJECT_DIR}/.git/config ]]; then + OLD_PWD=${PWD} + cd ${PROJECT_DIR}; + if [[ $( git diff -s --exit-code || echo $? ) -gt 0 ]]; then + echo "ABORTING!: Your repo has local changes which are not comitted." + echo "To avoid overwriting these changes, please commit your changes." + exit 1; + fi + cd $OLD_PWD; +fi BOOTSTRAPIT_GIT_URL="https://gitlab.com/mbarkhau/bootstrapit.git/" @@ -21,6 +29,8 @@ else cd $OLD_PWD; fi +md5sum=$(which md5sum || which md5) + old_md5=$( cat $PROJECT_DIR/scripts/bootstrapit_update.sh | $md5sum ); new_md5=$( cat $BOOTSTRAPIT_GIT_PATH/scripts/bootstrapit_update.sh | $md5sum ); @@ -28,6 +38,8 @@ if [[ $old_md5 != $new_md5 ]]; then # Copy the updated file, run it and exit the current execution. cp "${BOOTSTRAPIT_GIT_PATH}/scripts/bootstrapit_update.sh" \ "${PROJECT_DIR}/scripts/"; + git add "${PROJECT_DIR}/scripts/bootstrapit_update.sh"; + git commit --no-verify -m "auto update of scripts/bootstrapit_update.sh" source "${PROJECT_DIR}/scripts/bootstrapit_update.sh"; exit 0; fi @@ -140,7 +152,7 @@ if [[ -z $COPYRIGHT_STRING ]]; then fi if [[ -z $IS_PUBLIC ]]; then - IS_PUBLIC=$( echo $GIT_REPO_DOMAIN | grep -c -E '(gitlab\.com|github\.com|bitbucket\.org)' ); + IS_PUBLIC=$( echo $GIT_REPO_DOMAIN | grep -c -E '(gitlab\.com|github\.com|bitbucket\.org)' || true ); fi if [[ -z $PAGES_DOMAIN ]]; then @@ -185,22 +197,15 @@ fi GIT_REPO_PATH=$( echo "${GIT_REPO_URL}" | sed -E -e 's;https?://[^/]+/;;g' | sed -E 's;(/|.git)$;;g' ) GIT_REPO_NAME=$( echo "${GIT_REPO_PATH}" | sed -E -e 's;^[A-Za-z_-]+/;;g' ) -if [[ -f ${PROJECT_DIR}/.git/config ]]; then - OLD_PWD=${PWD} - cd ${PROJECT_DIR}; - if [[ $( git diff -s --exit-code || echo $? ) -gt 0 ]]; then - echo "ABORTING!: Your repo has local changes which are not comitted." - echo "To avoid overwriting these changes, please commit your changes." - exit 1; - fi - cd $OLD_PWD; +if [[ $LICENSE_ID =~ "none" ]]; then + echo $COPYRIGHT_STRING > $PROJECT_DIR/LICENSE; +else + cat $LICENSE_TXT_FILE \ + | sed "s/Copyright (c) [[:space:]]*/Copyright (c) $YEAR $AUTHOR_NAME ($AUTHOR_CONTACT)/g" \ + | sed "s/Copyright (c) [[:space:]]*/Copyright (c) $YEAR $AUTHOR_NAME ($AUTHOR_CONTACT)/g" \ + > $PROJECT_DIR/LICENSE; fi -cat $LICENSE_TXT_FILE \ - | sed "s/Copyright (c) [[:space:]]*/Copyright (c) $YEAR $AUTHOR_NAME ($AUTHOR_CONTACT)/g" \ - | sed "s/Copyright (c) [[:space:]]*/Copyright (c) $YEAR $AUTHOR_NAME ($AUTHOR_CONTACT)/g" \ - > $PROJECT_DIR/LICENSE; - function format_template() { cat $1 \