From 492ea04cc0fb7dc80d372d577c5c5f16115425ae Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Wed, 15 Mar 2017 10:47:47 -0400 Subject: [PATCH] Add update command. --- lib/commands/update.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/commands/update.sh diff --git a/lib/commands/update.sh b/lib/commands/update.sh new file mode 100644 index 00000000..20f50b1c --- /dev/null +++ b/lib/commands/update.sh @@ -0,0 +1,28 @@ +update_command() { + local update_to_head=$1 + + ( + cd $(asdf_dir) + pwd + + if [ "$update_to_head" = "--head" ]; then + # Update to latest on the master branch + git checkout master || exit 1 + + # Pull down the latest changes on master + git pull origin master || exit 1 + echo "Updated asdf to latest on the master branch" + else + # Update to latest release + git fetch --tags || exit 1 + tags=$(git tag) + + # Pick the newest tag + tag=$() + + # Update + git checkout "$tag" || exit 1 + echo "Updated asdf to release $tag" + fi + ) +}