From 8c9f13bb464533769e3e1c0f926533c39ce75b37 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 14 Dec 2023 10:26:44 -0700 Subject: [PATCH 1/5] Fix some whitespace --- bin/envconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/envconfig b/bin/envconfig index cc992a4..9448534 100755 --- a/bin/envconfig +++ b/bin/envconfig @@ -30,7 +30,7 @@ usage() { ) finish=true - + } parse_args() { @@ -114,7 +114,7 @@ if $INTERACTIVE ; then LSST_CONDA_ENV_NAME="${envs[${eid}]}" fi elif [[ $ENV_NAME != "" ]]; then - echo "Setting $ENV_NAME environment..." + echo "Setting $ENV_NAME environment..." LSST_CONDA_ENV_NAME=${ENV_NAME} elif [[ $BUILD_ID != "" ]]; then echo "Looking for the environment used in build ${BUILD_ID}..." From 2edb1e8ea5cef3f4049a3d62bbba506d48f91a62 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 14 Dec 2023 10:27:02 -0700 Subject: [PATCH 2/5] Fix getopts usage to make it more standard getopts allows you to say which options take arguments so you do not have to do the shift manually. This fixes the zsh implementation of getopts. --- bin/envconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/envconfig b/bin/envconfig index 9448534..d5221ba 100755 --- a/bin/envconfig +++ b/bin/envconfig @@ -37,15 +37,13 @@ parse_args() { local OPTIND local opt - while getopts "bnih" opt; do + while getopts "b:n:ih" opt; do case "$opt" in b) - shift; - BUILD_ID=$1 + BUILD_ID=${OPTARG} ;; n) - shift; - ENV_NAME=$1 + ENV_NAME=${OPTARG} ;; i) INTERACTIVE=true From db7ead7eba52ea78c5c792b3849412d74f1fdc16 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 14 Dec 2023 10:29:21 -0700 Subject: [PATCH 3/5] Fix some whitespace and line endings --- bin/envconfig.csh | 6 +++--- bin/mass-tag | 8 ++++---- bin/rebuild | 10 +++++----- bin/set_prereleased_env | 4 ++-- bin/setup.csh | 1 - bin/setup.sh | 1 - 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bin/envconfig.csh b/bin/envconfig.csh index cef9aca..81a8529 100644 --- a/bin/envconfig.csh +++ b/bin/envconfig.csh @@ -8,7 +8,7 @@ set BUILD_ID = "" if ( ! "$?1" ) then if ( "$1" == "-h" ) then - echo "Usage: source bin/envconfig.csh [-i] [-n] [-b] [-h]" + echo "Usage: source bin/envconfig.csh [-i] [-n] [-b] [-h]" echo echo " -i interactive, choose from a list of available environments" echo " -n NAME activate the environment NAME" @@ -94,7 +94,7 @@ if ( "$1" == "-i" ) then set env_list= ( `conda env list | grep -v "^#" | grep -v "^ " | grep -v "^base" | awk '{print $1}'` ) echo @ i = 0 - @ nenvs = $#env_list + @ nenvs = $#env_list echo "Found" $nenvs "environment(s):" while ( $i < $nenvs ) @ i++ @@ -118,7 +118,7 @@ if ( "$1" == "-i" ) then exit endif echo "Activating environment" $env_list[$eid] - set LSST_CONDA_ENV_NAME = ( $env_list[$eid] ) + set LSST_CONDA_ENV_NAME = ( $env_list[$eid] ) endif if ( ! $?LSST_SPLENV_REF) then diff --git a/bin/mass-tag b/bin/mass-tag index 2f50cb7..01ae759 100755 --- a/bin/mass-tag +++ b/bin/mass-tag @@ -6,14 +6,14 @@ if [[ -z $1 ]]; then (cat <<-EOF Usage: $0 [-d] - + -d : instead of setting it, delete the tag - + WARNING: THIS WILL APPLY TO ALL LSST/DMS REPOSITORIES IN ./build AND IMMEDIATELY PUSH THEM TO THE UPSTREAM GIT SERVER. - + EXERCISE EXTREME CAUTION. - + EOF ) >&2 exit 1 diff --git a/bin/rebuild b/bin/rebuild index 2a85533..160e889 100755 --- a/bin/rebuild +++ b/bin/rebuild @@ -31,10 +31,10 @@ usage() { fi # note that heredocs are prefixed with tab chars - fail "$(cat <<-EOF + fail "$(cat <<-EOF Usage: $0 [-p] [-n] [-u] [-r [-r [...]]] [-t ] product1 [product2 [...]] - Build one or more products. + Build one or more products. It requires that the environment has previously been setup using envconfig. Specific options: @@ -60,11 +60,11 @@ save_build_env() { # Saving environment information # Using conda-forge/rubin-env to create the environment, # there is no exact reference to refer to. - # + # # The information saved here has the following scopes: # - save the environment name corresponding to the buildID (locally) # to allow a new build based on the same environment. - # - persist the exact environment resolved for this build, since + # - persist the exact environment resolved for this build, since # this is not static, but will change with time. # This information is also placed in EUPS_PKGROOT by publish. @@ -157,7 +157,7 @@ fi ( cd "$VERSIONDB" current_branch="$(git branch --show-current)" - if [[ $current_branch != main ]]; then + if [[ $current_branch != main ]]; then git branch -m "$current_branch" main git fetch origin git branch -u origin/main main diff --git a/bin/set_prereleased_env b/bin/set_prereleased_env index 92c0602..08aa5a1 100755 --- a/bin/set_prereleased_env +++ b/bin/set_prereleased_env @@ -3,7 +3,7 @@ # Deploy a new environment using a given rubin-env fork and branch # # It is meant to be executed in after bin/deploy. -# The environment has to be enabled using envconfig -n +# The environment has to be enabled using envconfig -n # SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd) @@ -54,7 +54,7 @@ parse_args() { done shift $((OPTIND-1)) - if [ "$#" -ne 2 ]; then + if [ "$#" -ne 2 ]; then usage "Illegal number of parameters" fi diff --git a/bin/setup.csh b/bin/setup.csh index f57c09b..8483cb3 100644 --- a/bin/setup.csh +++ b/bin/setup.csh @@ -37,4 +37,3 @@ endif echo "Sourcing bin/envconfig.csh instead" echo source "$LSSTSW/bin/envconfig.csh" - diff --git a/bin/setup.sh b/bin/setup.sh index 9135b2b..dac6cd2 100644 --- a/bin/setup.sh +++ b/bin/setup.sh @@ -20,4 +20,3 @@ fi echo "Sourcing bin/envconfig instead" # shellcheck source=./bin/envconfig source "${LSSTSW}/bin/envconfig" 0 - From 83ba1cb91c3d53102d16f77a510af70ee783d118 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 14 Dec 2023 10:29:55 -0700 Subject: [PATCH 4/5] Add simple pre-commit file --- .pre-commit-config.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fdaa49c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + args: + - "--unsafe" + - id: end-of-file-fixer + - id: trailing-whitespace From 4af6b3ba44c6db2c50d3948755a204bcfc7f2126 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 14 Dec 2023 11:08:43 -0700 Subject: [PATCH 5/5] Modernize option handling for deploy --- bin/deploy | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/deploy b/bin/deploy index 1953e4f..ac38201 100755 --- a/bin/deploy +++ b/bin/deploy @@ -55,28 +55,25 @@ parse_args() { # We are intentionally not using gnu `getopt` due to portability concerns. # Sadly, this means no long options without a massive amount of boilerplate. - while getopts "hrvx" opt; do + while getopts "hr:v:x:" opt; do case "$opt" in h) usage ;; v) - shift; [[ -n $TAG ]] && usage "Cannot specify both -v and -x" [[ -n $ENVREF ]] && usage "Cannot specify both -v and -r" - ENV_VERSION=$1 + ENV_VERSION=${OPTARG} ;; x) - shift; [[ -n $ENV_VERSION ]] && usage "Cannot specify both -x and -v" [[ -n $ENVREF ]] && usage "Cannot specify both -x and -r" - TAG=$1 + TAG=${OPTARG} ;; r) - shift; [[ -n $TAG ]] && usage "Cannot specify both -r and -x" [[ -n $ENV_VERSION ]] && usage "Cannot specify both -r and -v" - ENVREF=$1 + ENVREF=${OPTARG} ;; *) usage "Unknown option: ${opt}"