From 78760f63245a96fb721b0f1aed140ffd087ef6c3 Mon Sep 17 00:00:00 2001 From: Manuel Barkhau Date: Wed, 26 Aug 2020 21:38:35 +0000 Subject: [PATCH] auto update of scripts/bootstrapit_update.sh --- scripts/bootstrapit_update.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/bootstrapit_update.sh b/scripts/bootstrapit_update.sh index 684684a..2a9247c 100644 --- a/scripts/bootstrapit_update.sh +++ b/scripts/bootstrapit_update.sh @@ -9,20 +9,23 @@ BOOTSTRAPIT_GIT_PATH=/tmp/bootstrapit; echo "Updating from $BOOTSTRAPIT_GIT_URL"; +OLD_PWD="$PWD"; + if [[ ! -e "$BOOTSTRAPIT_GIT_PATH" ]]; then git clone "$BOOTSTRAPIT_GIT_URL" "$BOOTSTRAPIT_GIT_PATH"; else - OLD_PWD="$PWD"; cd "$BOOTSTRAPIT_GIT_PATH"; git pull --quiet; cd "$OLD_PWD"; fi -BOOTSTRAPIT_DEBUG=0 +cd "$BOOTSTRAPIT_GIT_PATH"; +git checkout "${BOOTSTRAPIT_DEV_BRANCH-master}"; +git pull --quiet; +cd "$OLD_PWD"; -if [[ $BOOTSTRAPIT_DEBUG == 0 ]]; then +if [[ ${BOOTSTRAPIT_DEBUG-0} == 0 ]]; then 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." @@ -32,10 +35,10 @@ if [[ $BOOTSTRAPIT_DEBUG == 0 ]]; then cd "$OLD_PWD"; fi - md5sum=$(which md5sum || which md5) + md5cmd=$(command -v md5sum || command -v md5) - old_md5=$( cat "$PROJECT_DIR/scripts/bootstrapit_update.sh" | $md5sum ); - new_md5=$( cat "$BOOTSTRAPIT_GIT_PATH/scripts/bootstrapit_update.sh" | $md5sum ); + old_md5=$( $md5cmd < "$PROJECT_DIR/scripts/bootstrapit_update.sh" ); + new_md5=$( $md5cmd < "$BOOTSTRAPIT_GIT_PATH/scripts/bootstrapit_update.sh" ); if [[ "$old_md5" != "$new_md5" ]]; then # Copy the updated file, run it and exit the current execution. @@ -95,7 +98,7 @@ done set -- "${POSITIONAL[@]}" # restore positional parameters -if [[ -z $AUTHOR_EMAIL && ! -z $AUTHOR_CONTACT ]]; then +if [[ -z $AUTHOR_EMAIL && -n $AUTHOR_CONTACT ]]; then AUTHOR_EMAIL="${AUTHOR_CONTACT}" fi @@ -382,6 +385,7 @@ mkdir -p "${PROJECT_DIR}/stubs/"; mkdir -p "${PROJECT_DIR}/src/"; mkdir -p "${PROJECT_DIR}/requirements/"; mkdir -p "${PROJECT_DIR}/src/${MODULE_NAME}"; +mkdir -p "${PROJECT_DIR}/.github/workflows/"; copy_template .gitignore; copy_template README.md; @@ -407,6 +411,8 @@ copy_template requirements/integration.txt; copy_template requirements/vendor.txt; copy_template .gitlab-ci.yml; +copy_template .github/workflows/ci.yml; + copy_template scripts/update_conda_env_deps.sh; copy_template scripts/setup_conda_envs.sh; copy_template scripts/pre-push-hook.sh; @@ -434,16 +440,16 @@ for src_file in $src_files; do fi offset=0 if grep -z -q -E '^#![/a-z ]+?python' "$src_file"; then - let offset+=1; + (( offset+=1 )); fi if grep -q -E '^# .+?coding: [a-zA-Z0-9_\-]+' "$src_file"; then - let offset+=1; + (( offset+=1 )); fi rm -f "${src_file}.with_header"; if [[ $offset -gt 0 ]]; then head -n $offset "${src_file}" > "${src_file}.with_header"; fi - let offset+=1; + (( offset+=1 )); cat /tmp/.py_license.header >> "${src_file}.with_header"; tail -n +$offset "${src_file}" >> "${src_file}.with_header"; mv "${src_file}.with_header" "$src_file";