From d0ce81dfc51738a04fa07a7b1addcb9e462c8f3c Mon Sep 17 00:00:00 2001 From: Jay Gabriels Date: Sun, 19 Jan 2020 12:42:00 -0800 Subject: [PATCH] auto add trailing slash to path to clone to --- CHANGELOG.md | 1 + configs/configs.go | 7 ++++++- sample-conf.yaml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc14122b..15711368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) ## [Unreleased] - DATE ### Added +- auto add trailing slash to path to clone to if not supplied by user ### Changed ### Deprecated ### Removed diff --git a/configs/configs.go b/configs/configs.go index 97f235f5..580b37a6 100644 --- a/configs/configs.go +++ b/configs/configs.go @@ -123,7 +123,12 @@ func getOrSetDefaults(envVar string) { os.Setenv(envVar, "false") } } else { - os.Setenv(envVar, viper.GetString(envVar)) + // User forgot to put a / at the end of path, so we will add for them + if envVar == "GHORG_ABSOLUTE_PATH_TO_CLONE_TO" && !strings.HasSuffix(viper.GetString(envVar), "/") { + os.Setenv(envVar, viper.GetString(envVar)+"/") + } else { + os.Setenv(envVar, viper.GetString(envVar)) + } } } diff --git a/sample-conf.yaml b/sample-conf.yaml index a4c5ae83..32fe356c 100644 --- a/sample-conf.yaml +++ b/sample-conf.yaml @@ -1,5 +1,5 @@ --- -# This is where your *_ghorg directory will be created, use absolute pathing. Must end with / +# This is where your *_ghorg directory will be created, use absolute pathing. Must end with /, if not one will be added for you # default: $HOME/Desktop/ # flag (--path, -p) GHORG_ABSOLUTE_PATH_TO_CLONE_TO: