Upgrade to Go 1.19

This commit is contained in:
Mikołaj Pęczkowski 2022-12-10 23:47:59 +01:00
parent 2d06e8e09c
commit 741f18efd1
9 changed files with 20 additions and 28 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
build build
.idea

View File

@ -43,6 +43,7 @@ By default, the config file is searched for in `[HOME_DIR]./config/grm/config.ya
## Changelog ## 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.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.2.0 Add status command - get information about the current status in the repository
- 0.1.1 Allow to use env vars in config - 0.1.1 Allow to use env vars in config

View File

@ -1,8 +1,5 @@
version: '3' version: '3'
env:
go_dir:
tasks: tasks:
pull: pull:
cmds: cmds:
@ -10,10 +7,7 @@ tasks:
silent: true silent: true
test: test:
cmds: cmds:
- go test ./app - go test $(find . -name "*.go" -exec dirname {} \; | uniq | grep '/') -cover
- go test ./commands
- go test ./config
- go test ./echo
build: build:
cmds: cmds:
- mkdir -p build - mkdir -p build

View File

@ -12,8 +12,8 @@ import (
) )
const ( const (
APP_NAME = "Git repository manager" AppName = "Git repository manager"
APP_DESCRIPTION = "Manage your repository with simple app" AppDescription = "Manage your repository with simple app"
VERSION = "0.3.0" VERSION = "0.3.0"
errNotFoundTags = "no repository was found with the specified tags" errNotFoundTags = "no repository was found with the specified tags"
errNotFoundName = "no repository was found with the specified name" errNotFoundName = "no repository was found with the specified name"
@ -25,7 +25,7 @@ type GitRepositoryManager struct {
} }
func (g *GitRepositoryManager) Parse(args []string) error { 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 { if err != nil {
fmt.Printf("Error: %v", err.Error()) fmt.Printf("Error: %v", err.Error())
return err return err
@ -37,13 +37,13 @@ func (g *GitRepositoryManager) Parse(args []string) error {
return err return err
} }
fileExcension, err := getFileExcension(arguments.ConfigurationFile) fileExtension, err := getFileExtension(arguments.ConfigurationFile)
if err != nil { if err != nil {
fmt.Printf("Error: %v", err.Error()) fmt.Printf("Error: %v", err.Error())
return err return err
} }
configuration, err := config.GetRepositoryConfig(configFileContent, fileExcension) configuration, err := config.GetRepositoryConfig(configFileContent, fileExtension)
if err != nil { if err != nil {
fmt.Printf("Error: %v", err.Error()) fmt.Printf("Error: %v", err.Error())
return err return err

View File

@ -3,27 +3,27 @@ package app
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "os"
"strings" "strings"
"gitlab.com/revalus/grm/config" "gitlab.com/revalus/grm/config"
) )
func getFileContent(pathToFile string) ([]byte, error) { func getFileContent(pathToFile string) ([]byte, error) {
return ioutil.ReadFile(pathToFile) return os.ReadFile(pathToFile)
} }
func getFileExcension(pathToFile string) (string, error) { func getFileExtension(pathToFile string) (string, error) {
splittedFileName := strings.Split(pathToFile, ".") splitFileName := strings.Split(pathToFile, ".")
if len(splittedFileName) == 1 { if len(splitFileName) == 1 {
msg := fmt.Sprintf("excension for file \"%v\", not found", splittedFileName) msg := fmt.Sprintf("excension for file \"%v\", not found", splitFileName)
return "", errors.New(msg) 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 { func checkIsItemInSlice(check string, sliceToCheck []string) bool {

View File

@ -16,7 +16,7 @@ func TestGetFileExtension(t *testing.T) {
} }
for key, value := range toTest { for key, value := range toTest {
result, err := getFileExcension(key) result, err := getFileExtension(key)
if err != nil { if err != nil {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", err)
@ -32,7 +32,7 @@ func TestGetFileExtension(t *testing.T) {
func TestErrorInGetExcensionFile(t *testing.T) { func TestErrorInGetExcensionFile(t *testing.T) {
result, err := getFileExcension("test") result, err := getFileExtension("test")
if err == nil { if err == nil {
t.Errorf("Expected to get error, instead of this got result %v", result) t.Errorf("Expected to get error, instead of this got result %v", result)

2
go.mod
View File

@ -1,6 +1,6 @@
module gitlab.com/revalus/grm module gitlab.com/revalus/grm
go 1.17 go 1.19
require ( require (
github.com/akamensky/argparse v1.3.1 github.com/akamensky/argparse v1.3.1

2
go.sum
View File

@ -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-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-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-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-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-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/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/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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 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/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= 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= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -6,8 +6,6 @@ import (
"gitlab.com/revalus/grm/app" "gitlab.com/revalus/grm/app"
) )
const ()
func main() { func main() {
app := app.GitRepositoryManager{} app := app.GitRepositoryManager{}