Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
uses: golangci/golangci-lint-action@v8
with:
# If you change this, make sure to also update scripts/golangci-lint-shim.sh
version: v2.4.0
version: v2.5.0
- name: errors
run: golangci-lint run
if: ${{ failure() }}
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ test: unit-test integration-test-all
generate:
go generate ./...

# If you execute `gofumpt -l -w .`, it will format all Go files in the current directory, including `test/_results/*` files.
# We pass only Git-tracked Go files to gofumpt because we don't want to format the test results or get errors from it.
.PHONY: format
format:
git ls-files '*.go' ':!vendor' | xargs gofumpt -l -w
go run mvdan.cc/gofumpt@v0.9.1 -l -w .

.PHONY: lint
lint:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module github.com/jesseduffield/lazygit

go 1.25.0

// This is necessary to ignore test files when executing gofumpt.
ignore ./test

require (
dario.cat/mergo v1.0.1
github.com/adrg/xdg v0.4.0
Expand Down
28 changes: 14 additions & 14 deletions pkg/commands/oscommands/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ import (
func CopyFile(src, dst string) (err error) {
in, err := os.Open(src)
if err != nil {
return //nolint: nakedret
return err
}
defer in.Close()

out, err := os.Create(dst)
if err != nil {
return //nolint: nakedret
return err
}
defer func() {
if e := out.Close(); e != nil {
Expand All @@ -54,24 +54,24 @@ func CopyFile(src, dst string) (err error) {

_, err = io.Copy(out, in)
if err != nil {
return //nolint: nakedret
return err
}

err = out.Sync()
if err != nil {
return //nolint: nakedret
return err
}

si, err := os.Stat(src)
if err != nil {
return //nolint: nakedret
return err
}
err = os.Chmod(dst, si.Mode())
if err != nil {
return //nolint: nakedret
return err
}

return //nolint: nakedret
return err
}

// CopyDir recursively copies a directory tree, attempting to preserve permissions.
Expand All @@ -91,7 +91,7 @@ func CopyDir(src string, dst string) (err error) {

_, err = os.Stat(dst)
if err != nil && !os.IsNotExist(err) {
return //nolint: nakedret
return err
}
if err == nil {
// it exists so let's remove it
Expand All @@ -102,12 +102,12 @@ func CopyDir(src string, dst string) (err error) {

err = os.MkdirAll(dst, si.Mode())
if err != nil {
return //nolint: nakedret
return err
}

entries, err := os.ReadDir(src)
if err != nil {
return //nolint: nakedret
return err
}

for _, entry := range entries {
Expand All @@ -117,13 +117,13 @@ func CopyDir(src string, dst string) (err error) {
if entry.IsDir() {
err = CopyDir(srcPath, dstPath)
if err != nil {
return //nolint: nakedret
return err
}
} else {
var info os.FileInfo
info, err = entry.Info()
if err != nil {
return //nolint: nakedret
return err
}

// Skip symlinks.
Expand All @@ -133,10 +133,10 @@ func CopyDir(src string, dst string) (err error) {

err = CopyFile(srcPath, dstPath)
if err != nil {
return //nolint: nakedret
return err
}
}
}

return //nolint: nakedret
return err
}
13 changes: 7 additions & 6 deletions pkg/gui/presentation/branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
"github.com/xo/terminfo"
)

func makeAtomic(v int32) (result atomic.Int32) {
func makeAtomic(v int32) *atomic.Int32 {
var result atomic.Int32
result.Store(v)
return //nolint: nakedret
return &result
}

func Test_getBranchDisplayStrings(t *testing.T) {
Expand Down Expand Up @@ -109,7 +110,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
branch: &models.Branch{
Name: "branch_name",
Recency: "1m",
BehindBaseBranch: makeAtomic(2),
BehindBaseBranch: *makeAtomic(2),
},
itemOperation: types.ItemOperationNone,
fullDescription: false,
Expand All @@ -126,7 +127,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
UpstreamRemote: "origin",
AheadForPull: "0",
BehindForPull: "0",
BehindBaseBranch: makeAtomic(2),
BehindBaseBranch: *makeAtomic(2),
},
itemOperation: types.ItemOperationNone,
fullDescription: false,
Expand All @@ -143,7 +144,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
UpstreamRemote: "origin",
AheadForPull: "3",
BehindForPull: "5",
BehindBaseBranch: makeAtomic(2),
BehindBaseBranch: *makeAtomic(2),
},
itemOperation: types.ItemOperationNone,
fullDescription: false,
Expand Down Expand Up @@ -247,7 +248,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
UpstreamRemote: "origin",
AheadForPull: "3",
BehindForPull: "5",
BehindBaseBranch: makeAtomic(4),
BehindBaseBranch: *makeAtomic(4),
},
itemOperation: types.ItemOperationNone,
fullDescription: false,
Expand Down
2 changes: 1 addition & 1 deletion scripts/golangci-lint-shim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
set -e

# Must be kept in sync with the version in .github/workflows/ci.yml
version="v2.4.0"
version="v2.5.0"

go run "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$version" "$@"
Loading