Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
go.sum -diff
*.sum -diff
*_gen.go -diff
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.21.x

- name: Build
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ on:
- master

jobs:
lint: # golangci:
name: lint
lint:
name: lint-full
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.21.x

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.17.x]
go-version: [1.21.x]
os: [ubuntu-latest]
runs-on: ubuntu-latest
steps:
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.21.x

- name: Test
shell: bash
Expand Down
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/bin
.DS_STORE
/.idea
/.vscode
/.run
.DS_STORE
.DS_Store

/bin
coverage.out
/.run
50 changes: 31 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
export GO111MODULE=on
export GOSUMDB=off

LOCAL_BIN = $(CURDIR)/bin
GOBIN = $(GOPATH)/bin
GOARCH = amd64
ENV_PARAMS ?= CGO_ENABLED=0
LOCAL_BIN := $(CURDIR)/bin
LINT_BIN := $(LOCAL_BIN)/golangci-lint

.PHONY: bin-deps
bin-deps:
$(info Installing binary dependencies...)
GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
.PHONY: deps
deps:
$(info Download dependencies...)
go mod download

.PHONY: test
test:
$(info Running test...)
go test ./...

.PHONY: .lint
.lint:
$(LOCAL_BIN)/golangci-lint run --config=.golangci.yaml ./...
$(info Running lint...)
$(LINT_BIN) run --new-from-rev=origin/master --config=.golangci.yaml ./...

.PHONY: .lint-full
.lint-full:
$(info Running lint-full...)
$(LINT_BIN) run --config=.golangci.yaml ./...

.PHONY: lint
lint: install-lint .lint

.PHONY: lint
lint: bin-deps .lint
.PHONY: lint-full
lint-full: install-lint .lint-full

LINT_TAG ?= 1.55.2
install-lint: export GOBIN := $(LOCAL_BIN)
install-lint:
$(info Installing golangci-lint v$(LINT_TAG))
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_TAG)
go mod tidy

.PHONY: build
build: build-linux build-darwin
Expand All @@ -29,11 +49,3 @@ build-linux:
build-darwin:
go mod download && CGO_ENABLED=0 \
GOOS=darwin GOARCH=${GOARCH} go build -o ${LOCAL_BIN}/git-update-darwin-${GOARCH} ./cmd/main.go;

.PHONY: test
test:
go test ./... -count=1 -timeout=60s -v -short

.PHONY: install
install:
go build -o $(GOBIN)/protogen -ldflags "$(LDFLAGS)" $(CURDIR)/cmd
9 changes: 3 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module github.com/Format-C-eft/git-update

go 1.19
go 1.21

require (
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.1
)
require github.com/spf13/cobra v1.8.0

require (
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
12 changes: 5 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package cmd

import (
"context"
"errors"
"fmt"
"os"
"strings"
"sync"

"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/Format-C-eft/git-update/internal/shell_executor"
Expand All @@ -34,7 +34,7 @@ func cmdRun(_ *cobra.Command, _ []string) error {

listDir, err := getListOfDirectories()
if err != nil {
return errors.Wrap(err, "getListOfDirectories")
return fmt.Errorf("getListOfDirectories err: %w", err)
}

if len(listDir) == 0 {
Expand All @@ -55,7 +55,7 @@ func cmdRun(_ *cobra.Command, _ []string) error {
func getListOfDirectories() ([]string, error) {
list, err := os.ReadDir(flagDir)
if err != nil {
return nil, errors.Wrap(err, "os.ReadDir")
return nil, fmt.Errorf("os.ReadDir err: %w", err)
}

listDir := make([]string, 0, len(list))
Expand Down
4 changes: 1 addition & 3 deletions internal/shell_executor/shell_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"context"
"fmt"
"os/exec"

"github.com/pkg/errors"
)

func Run(ctx context.Context, dir string, cmdline ...string) ([]byte, error) {
Expand All @@ -20,7 +18,7 @@ func Run(ctx context.Context, dir string, cmdline ...string) ([]byte, error) {
err := cmd.Run()

if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("%s in %s error: %s", cmdline, dir, stderr.String()))
return nil, fmt.Errorf("%s in %s cmd_error: %s err: %w", cmdline, dir, stderr.String(), err)
}

return stdout.Bytes(), nil
Expand Down