Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add git --before option #152

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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."
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -110,6 +119,9 @@ while [[ $# -gt 0 ]]; do
--skip-clone)
opt_skip_clone=1
;;
--before=*)
opt_before_date=${arg#*=}
;;
--help)
usage
exit 0
Expand Down Expand Up @@ -155,6 +167,16 @@ 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)"
# Maybe use https://github.com/astrofrog/pypi-timemachine for pip.
# What to do with conda?
fi

echo "==== Create $env_name conda environment"

[[ -z $conda_env_file ]] && conda_env_file="$mcsrc/conda-env.yml"
Expand Down