From 45e1ec892f9c04124204c363481daf8dbf3eca24 Mon Sep 17 00:00:00 2001 From: Jay Gabriels Date: Sat, 11 Jul 2020 12:35:14 -0700 Subject: [PATCH] bump version to 1.3.1 --- .gitignore | 1 + CHANGELOG.md | 19 +++++++++++++++++++ cmd/clone.go | 10 +++++++++- cmd/clone_test.go | 12 +++++++++++- cmd/version.go | 2 +- configs/configs.go | 11 ++++++++++- sample-conf.yaml | 2 +- 7 files changed, 52 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f740c2a..1ad4ba8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ ghorg .env debug .DS_Store +coverage.out diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da5402..bd7b797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +## [1.3.2] - unrealeased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security + +## [1.3.1] - 07/11/20 +### Added +- ascii time output when users use ghorgignore +- ascii time output when users use output-dir flag +### Changed +- default GHORG_ABSOLUTE_PATH_TO_CLONE_TO to $HOME/Desktop/ghorg +### Deprecated +### Removed +### Fixed +### Security + ## [1.3.0] - 07/11/20 ### Added - auto downcase of ghorg clone folder name; thanks @zamariola diff --git a/cmd/clone.go b/cmd/clone.go index 2db233b..c934ad3 100644 --- a/cmd/clone.go +++ b/cmd/clone.go @@ -46,7 +46,7 @@ func init() { rootCmd.PersistentFlags().StringVarP(&color, "color", "", "", "GHORG_COLOR - toggles colorful output on/off (default on)") rootCmd.AddCommand(cloneCmd) cloneCmd.Flags().StringVar(&protocol, "protocol", "", "GHORG_CLONE_PROTOCOL - protocol to clone with, ssh or https, (default https)") - cloneCmd.Flags().StringVarP(&path, "path", "p", "", "GHORG_ABSOLUTE_PATH_TO_CLONE_TO - absolute path the ghorg_* directory will be created. Must end with / (default $HOME/Desktop/)") + cloneCmd.Flags().StringVarP(&path, "path", "p", "", "GHORG_ABSOLUTE_PATH_TO_CLONE_TO - absolute path the ghorg_* directory will be created. Must end with / (default $HOME/Desktop/ghorg)") cloneCmd.Flags().StringVarP(&branch, "branch", "b", "", "GHORG_BRANCH - branch left checked out for each repo cloned (default master)") cloneCmd.Flags().StringVarP(&token, "token", "t", "", "GHORG_GITHUB_TOKEN/GHORG_GITLAB_TOKEN/GHORG_BITBUCKET_APP_PASSWORD - scm token to clone with") cloneCmd.Flags().StringVarP(&bitbucketUsername, "bitbucket-username", "", "", "GHORG_BITBUCKET_USERNAME - bitbucket only: username associated with the app password") @@ -487,6 +487,7 @@ func PrintConfigs() { colorlog.PrintInfo("* Branch : " + os.Getenv("GHORG_BRANCH")) colorlog.PrintInfo("* Location : " + os.Getenv("GHORG_ABSOLUTE_PATH_TO_CLONE_TO")) colorlog.PrintInfo("* Concurrency : " + os.Getenv("GHORG_CONCURRENCY")) + if os.Getenv("GHORG_SCM_BASE_URL") != "" { colorlog.PrintInfo("* Base URL : " + os.Getenv("GHORG_SCM_BASE_URL")) } @@ -496,6 +497,13 @@ func PrintConfigs() { if os.Getenv("GHORG_BACKUP") == "true" { colorlog.PrintInfo("* Backup : " + os.Getenv("GHORG_BACKUP")) } + if configs.GhorgIgnoreDetected() == true { + colorlog.PrintInfo("* Ghorgignore : true") + } + if os.Getenv("GHORG_OUTPUT_DIR") != "" { + colorlog.PrintInfo("* Output Dir : " + parentFolder + "_ghorg") + } + colorlog.PrintInfo("*************************************") fmt.Println("") } diff --git a/cmd/clone_test.go b/cmd/clone_test.go index 034b429..5f983b0 100644 --- a/cmd/clone_test.go +++ b/cmd/clone_test.go @@ -14,10 +14,20 @@ func TestShouldLowerRegularString(t *testing.T) { func TestShouldNotChangeLowerCasedRegularString(t *testing.T) { + lowerName := "repo_name" + parseParentFolder([]string{lowerName}) + + if parentFolder != "repo_name" { + t.Errorf("Wrong folder name, expected: %s, got: %s", lowerName, parentFolder) + } +} + +func TestReplaceDashWithUnderscore(t *testing.T) { + lowerName := "repo-name" parseParentFolder([]string{lowerName}) - if parentFolder != "repo-name" { + if parentFolder != "repo_name" { t.Errorf("Wrong folder name, expected: %s, got: %s", lowerName, parentFolder) } } diff --git a/cmd/version.go b/cmd/version.go index 2ecbe11..82677f4 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -15,6 +15,6 @@ var versionCmd = &cobra.Command{ Short: "Print the version number of Ghorg", Long: `All software has versions. This is Ghorg's`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("1.3.0") + fmt.Println("1.3.1") }, } diff --git a/configs/configs.go b/configs/configs.go index 6195c45..d53bb2f 100644 --- a/configs/configs.go +++ b/configs/configs.go @@ -114,7 +114,7 @@ func getOrSetDefaults(envVar string) { if viper.GetString(envVar) == "" { switch envVar { case "GHORG_ABSOLUTE_PATH_TO_CLONE_TO": - os.Setenv(envVar, HomeDir()+"/Desktop/") + os.Setenv(envVar, HomeDir()+"/Desktop/ghorg/") case "GHORG_BRANCH": os.Setenv(envVar, "master") case "GHORG_CLONE_PROTOCOL": @@ -151,6 +151,15 @@ func GhorgIgnoreLocation() string { return GhorgDir() + "/ghorgignore" } +// GhorgIgnoreDetected identify if a ghorgignore file exists in users .config/ghorg directory +func GhorgIgnoreDetected() bool { + _, err := os.Stat(GhorgIgnoreLocation()) + if os.IsNotExist(err) { + return false + } + return true +} + // GhorgDir returns the ghorg directory path func GhorgDir() string { if XConfigHomeSet() { diff --git a/sample-conf.yaml b/sample-conf.yaml index 8bd460e..86e8e6f 100644 --- a/sample-conf.yaml +++ b/sample-conf.yaml @@ -62,7 +62,7 @@ GHORG_SCM_TYPE: GHORG_CLONE_PROTOCOL: # 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/ +# default: $HOME/Desktop/ghorg # flag (--path, -p) GHORG_ABSOLUTE_PATH_TO_CLONE_TO: