From d445ea5fc449ac08bf663a7f66d414f66c985eef Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 15 Sep 2022 15:58:49 -0500 Subject: [PATCH 1/2] add --before feature --- install.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/install.sh b/install.sh index 1acc252..40939ac 100755 --- a/install.sh +++ b/install.sh @@ -15,6 +15,11 @@ if ! command -v mpicc &> /dev/null ;then exit 2 fi +function version +{ + echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; +} + usage() { @@ -32,6 +37,7 @@ usage() echo " --git-ssh Use SSH-based URL to clone mirgecom." echo " --debug Show debugging output of this script (set -x)." echo " --skip-clone Skip cloning mirgecom, assume it will be manually copied." + echo " --before=DATE Check out a specific version of the branch before DATE (in the form yyyy-mm-dd)." echo " --help Print this help text." } @@ -59,6 +65,9 @@ opt_git_ssh=0 # Skip cloning mirgecom opt_skip_clone=0 +# Check out version of the branch before a certain date +opt_before_date= + while [[ $# -gt 0 ]]; do arg=$1 shift @@ -110,6 +119,9 @@ while [[ $# -gt 0 ]]; do --skip-clone) opt_skip_clone=1 ;; + --before=*) + opt_before_date=${arg#*=} + ;; --help) usage exit 0 @@ -155,6 +167,14 @@ if [[ $opt_skip_clone -eq 0 ]]; then fi fi +if [[ -n $opt_before_date ]]; then + if [[ $(version "$(git --version | awk '{print $3}')") -ge $(version "2.23.0") ]]; then + echo "Your git version is too old for the --before option, please upgrade to 2.23 or newer." + exit 4 + fi + git checkout "$(git rev-list -n1 --before=$opt_before_date $mcbranch)" +fi + echo "==== Create $env_name conda environment" [[ -z $conda_env_file ]] && conda_env_file="$mcsrc/conda-env.yml" From 3290e02a61c5219bc9ccb762ca29920ea884f4ae Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 15 Sep 2022 16:15:49 -0500 Subject: [PATCH 2/2] add comment --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 40939ac..e113a94 100755 --- a/install.sh +++ b/install.sh @@ -173,6 +173,8 @@ if [[ -n $opt_before_date ]]; then exit 4 fi git checkout "$(git rev-list -n1 --before=$opt_before_date $mcbranch)" + # Maybe use https://github.com/astrofrog/pypi-timemachine for pip. + # What to do with conda? fi echo "==== Create $env_name conda environment"