From 5d6b3688f2d160a560a40aed64c95be36d766c8e Mon Sep 17 00:00:00 2001 From: Bhupesh Varshney Date: Fri, 2 Feb 2024 23:11:16 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20improve=20support=20for=20runnin?= =?UTF-8?q?g=20ugit=20via=20docker=20(#68)=20(#69)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - don't update ugit inside docker - instead of opening a browser, print the guide URL - remove usage of basename on help text (#66) --- ugit | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ugit b/ugit index 330eded..6b20eac 100755 --- a/ugit +++ b/ugit @@ -421,8 +421,9 @@ check_deps() { show_version() { printf "ugit version %s\n" "$VERSION" } + print_help() { - printf "Usage: %s [-h] [-v] [-u] [-g]\n" "$(basename "${BASH_SOURCE[0]}")" + printf "Usage: %s [-h] [-v] [-u] [-g]\n" "ugit" printf "ugit helps you undo git commands without much effort\n" printf "Just run 'ugit' and search for what you want to undo\n\n" printf "Available options:\n" @@ -443,6 +444,12 @@ get_changelog() { } ugit_update() { + if [ -n "${UGIT_RUNNING_IN_DOCKER-}" ] && [ "$UGIT_RUNNING_IN_DOCKER" = true ]; then + printf "%s\n\n" "You are running version ${VERSION} of ugit via Docker. Please pull the latest docker image to update." + printf "\t%s\n" "${BOLD_ORG_FG}docker pull bhupeshimself/ugit${RESET}" + return + fi + printf "%s\n" "Checking for updates ..." curl -s -L "$SCRIPT_URL" > "$TMP_FILE" NEW_VER=$(grep "^VERSION" "$TMP_FILE" | awk -F'[="]' '{print $3}') @@ -462,7 +469,12 @@ ugit_update() { } open_guide() { - GUIDE="https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git" + GUIDE="https://til.bhupesh.me/git/how-to-undo-anything-in-git" + + if [ -n "${UGIT_RUNNING_IN_DOCKER-}" ] && [ "$UGIT_RUNNING_IN_DOCKER" = true ]; then + printf "%s\n" "You can find how ugit does its magic at: ${BOLD_ORG_FG}${GUIDE}${RESET}" + return + fi case "$OSTYPE" in darwin*)