Create switch-branch.sh

This commit is contained in:
Ross Smith II 2021-06-06 13:39:59 -07:00 committed by GitHub
parent 234327358d
commit 84b4714f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

32
switch-branch.sh Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
NANO_VER=$(nano --version 2>/dev/null | awk '/version/ {print $4}' | awk -F . '{printf("%d%02d%02d", $1, $2, $3)}')
if [[ -z "${NANO_VER}" ]]; then
printf "Cannot determine nano's version\\n" >&2
exit 1
fi
printf 'Found nano version %s\n' "$(nano --version 2>/dev/null | awk '/version/ {print $4}')"
if ((NANO_VER < 20105)); then
NANO_BRANCH='pre-2.1.5'
elif ((NANO_VER < 20299)); then
NANO_BRANCH='pre-2.2.99'
elif ((NANO_VER < 20302)); then
NANO_BRANCH='pre-2.3.2'
elif ((NANO_VER < 20503)); then
NANO_BRANCH='pre-2.5.3'
elif ((NANO_VER < 20905)); then
NANO_BRANCH='pre-2.9.5'
elif ((NANO_VER < 40500)); then
NANO_BRANCH='pre-4.5'
elif ((NANO_VER < 50000)); then
NANO_BRANCH='pre-5.0'
else
NANO_BRANCH='master'
fi
printf 'Switching to branch %s\n' "${NANO_BRANCH}"
git checkout "${NANO_BRANCH}"