From 741f18efd1a9a3c593eaec52cd7dea0796a65216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20P=C4=99czkowski?= Date: Sat, 10 Dec 2022 23:47:59 +0100 Subject: [PATCH] Upgrade to Go 1.19 --- .gitignore | 3 ++- README.md | 1 + Taskfile.yml | 8 +------- app/app.go | 10 +++++----- app/utils.go | 16 ++++++++-------- app/utils_test.go | 4 ++-- go.mod | 2 +- go.sum | 2 -- main.go | 2 -- 9 files changed, 20 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index c795b05..b7c1c7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build \ No newline at end of file +build +.idea \ No newline at end of file diff --git a/README.md b/README.md index eceb64f..cd34bc4 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ By default, the config file is searched for in `[HOME_DIR]./config/grm/config.ya ## Changelog +- 0.3.1 Upgrade to Go 1.19 - 0.3.0 Adding the ability to limit actions to repositories containing a given name or tags - 0.2.0 Add status command - get information about the current status in the repository - 0.1.1 Allow to use env vars in config diff --git a/Taskfile.yml b/Taskfile.yml index 7c09d02..de71000 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,8 +1,5 @@ version: '3' -env: - go_dir: - tasks: pull: cmds: @@ -10,10 +7,7 @@ tasks: silent: true test: cmds: - - go test ./app - - go test ./commands - - go test ./config - - go test ./echo + - go test $(find . -name "*.go" -exec dirname {} \; | uniq | grep '/') -cover build: cmds: - mkdir -p build diff --git a/app/app.go b/app/app.go index 0cffc00..6b2a2fa 100644 --- a/app/app.go +++ b/app/app.go @@ -12,8 +12,8 @@ import ( ) const ( - APP_NAME = "Git repository manager" - APP_DESCRIPTION = "Manage your repository with simple app" + AppName = "Git repository manager" + AppDescription = "Manage your repository with simple app" VERSION = "0.3.0" errNotFoundTags = "no repository was found with the specified tags" errNotFoundName = "no repository was found with the specified name" @@ -25,7 +25,7 @@ type GitRepositoryManager struct { } func (g *GitRepositoryManager) Parse(args []string) error { - arguments, err := config.ParseCliArguments(APP_NAME, APP_DESCRIPTION, args) + arguments, err := config.ParseCliArguments(AppName, AppDescription, args) if err != nil { fmt.Printf("Error: %v", err.Error()) return err @@ -37,13 +37,13 @@ func (g *GitRepositoryManager) Parse(args []string) error { return err } - fileExcension, err := getFileExcension(arguments.ConfigurationFile) + fileExtension, err := getFileExtension(arguments.ConfigurationFile) if err != nil { fmt.Printf("Error: %v", err.Error()) return err } - configuration, err := config.GetRepositoryConfig(configFileContent, fileExcension) + configuration, err := config.GetRepositoryConfig(configFileContent, fileExtension) if err != nil { fmt.Printf("Error: %v", err.Error()) return err diff --git a/app/utils.go b/app/utils.go index bdbdfdc..8263379 100644 --- a/app/utils.go +++ b/app/utils.go @@ -3,27 +3,27 @@ package app import ( "errors" "fmt" - "io/ioutil" + "os" "strings" "gitlab.com/revalus/grm/config" ) func getFileContent(pathToFile string) ([]byte, error) { - return ioutil.ReadFile(pathToFile) + return os.ReadFile(pathToFile) } -func getFileExcension(pathToFile string) (string, error) { - splittedFileName := strings.Split(pathToFile, ".") +func getFileExtension(pathToFile string) (string, error) { + splitFileName := strings.Split(pathToFile, ".") - if len(splittedFileName) == 1 { - msg := fmt.Sprintf("excension for file \"%v\", not found", splittedFileName) + if len(splitFileName) == 1 { + msg := fmt.Sprintf("excension for file \"%v\", not found", splitFileName) return "", errors.New(msg) } - fileExcension := splittedFileName[len(splittedFileName)-1] + fileExtension := splitFileName[len(splitFileName)-1] - return fileExcension, nil + return fileExtension, nil } func checkIsItemInSlice(check string, sliceToCheck []string) bool { diff --git a/app/utils_test.go b/app/utils_test.go index ed4df90..5239e55 100644 --- a/app/utils_test.go +++ b/app/utils_test.go @@ -16,7 +16,7 @@ func TestGetFileExtension(t *testing.T) { } for key, value := range toTest { - result, err := getFileExcension(key) + result, err := getFileExtension(key) if err != nil { t.Errorf("Unexpected error: %v", err) @@ -32,7 +32,7 @@ func TestGetFileExtension(t *testing.T) { func TestErrorInGetExcensionFile(t *testing.T) { - result, err := getFileExcension("test") + result, err := getFileExtension("test") if err == nil { t.Errorf("Expected to get error, instead of this got result %v", result) diff --git a/go.mod b/go.mod index 2896766..a791937 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module gitlab.com/revalus/grm -go 1.17 +go 1.19 require ( github.com/akamensky/argparse v1.3.1 diff --git a/go.sum b/go.sum index 91471eb..4055321 100644 --- a/go.sum +++ b/go.sum @@ -94,7 +94,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -104,7 +103,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go index 51cd378..a1fcb07 100644 --- a/main.go +++ b/main.go @@ -6,8 +6,6 @@ import ( "gitlab.com/revalus/grm/app" ) -const () - func main() { app := app.GitRepositoryManager{}