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
108 changes: 67 additions & 41 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,81 @@
# More info on config here: https://golangci-lint.run/usage/configuration/#config-file
version: "2"
run:
concurrency: 8
timeout: 10m
issues-exit-code: 1
tests: true

output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
govet:
enable:
- shadow
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2

linters:
disable-all: true
default: none
enable:
- dupl
- durationcheck
- errorlint
- errcheck
- goconst
- goimports
- gosec
- gosimple
- govet
- ineffassign
- revive
- staticcheck
- unused

issues:
exclude-dirs:
- bin
- vendor
- var
- tmp
- .cache
exclude-use-default: false
exclude:
- G104
- G115
- G204
- should have a package comment
- should have comment or be unexported
- comment on exported const
- should have comment \(or a comment on this block\)
- don't use an underscore in package name
- package-comments
- wsl_v5
settings:
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
govet:
enable:
- shadow
wsl_v5:
enable:
- assign
- branch
- decl
- defer
- expr
- for
- go
- if
- inc-dec
- label
- range
- return
- select
- switch
- type-switch
- append
- assign-expr
- err
- leading-whitespace
- trailing-whitespace
exclusions:
generated: lax
rules:
- path: (.+)\.go$
text: G104
- path: (.+)\.go$
text: G115
- path: (.+)\.go$
text: G204
- path: (.+)\.go$
text: should have a package comment
- path: (.+)\.go$
text: should have comment or be unexported
- path: (.+)\.go$
text: comment on exported const
- path: (.+)\.go$
text: should have comment \(or a comment on this block\)
- path: (.+)\.go$
text: don't use an underscore in package name
- path: (.+)\.go$
text: package-comments
paths:
- bin
- vendor
- var
- tmp
- .cache
- third_party$
- builtin$
- examples$
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CURDIR_ESCAPE:=$(subst $(space),\ ,$(CURDIR))

LOCAL_BIN:=$(CURDIR_ESCAPE)/bin
LINT_BIN:=$(LOCAL_BIN)/golangci-lint
LINT_VERSION:=1.60.3
LINT_VERSION:=2.5.0

###### TEST ######
.PHONY: test
Expand All @@ -23,13 +23,12 @@ test:
install-lint:
ifeq ($(wildcard $(LINT_BIN)),)
$(info Installing golangci-lint v$(LINT_VERSION))
GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$(LINT_VERSION)
GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$(LINT_VERSION)
# Устанавливаем текущий путь для исполняемого файла линтера.
else
$(info Golangci-lint is already installed to $(LINT_VERSION))
endif


PHONY: lint
lint: install-lint
$(info Running lint against changed files...)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/Format-C-eft/git-update

go 1.23
go 1.25
1 change: 1 addition & 0 deletions internal/cmd/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ func (r *resultLog) String() string {
),
)
}

return strings.Join(result, "\n")
}
9 changes: 7 additions & 2 deletions internal/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ func Run() error {
ctx, cancel := context.WithTimeout(context.Background(), execTimeout)
defer cancel()

var countDone atomic.Int32
var countAll = int32(len(listDir))
var (
countDone atomic.Int32
countAll = int32(len(listDir))
)

for {
select {
Expand All @@ -64,6 +66,7 @@ func Run() error {
case logChan := <-ch:
fmt.Println(logChan.String())
fmt.Println("--------------------------------------------------------------------")

if newValue := countDone.Add(1); newValue >= countAll {
return nil
}
Expand Down Expand Up @@ -93,6 +96,7 @@ func processDir(dir string, ch chan resultLog) {

defer func() {
resultLogs.AddLog("stop processing", "")

ch <- resultLogs
}()

Expand All @@ -112,6 +116,7 @@ func processDir(dir string, ch chan resultLog) {
resultLogs.AddLog("skipped: there are uncommitted changes", "")
return
}

result, err := shell_executor.Run(ctx, dir, "git", "reset", "--hard")
if err != nil {
resultLogs.AddLog("error: git reset --hard", err.Error())
Expand Down
Loading