Skip to content

Commit 32a701c

Browse files
authored
Use ignore directive to ignore test files not to be passes to gofumpt (#4936)
### Motivation To replace the workaround introduced in #4809 with `ignore` directive to make the code simpler. ### Overview This is a follow-up PR to #4809. I have added 4 changes due to updating gofumpt to remove `git ls-files` workaround. Please take a look at each commit messages for details.
2 parents 6782f04 + 64bcc72 commit 32a701c

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ test: unit-test integration-test-all
3434
generate:
3535
go generate ./...
3636

37-
# If you execute `gofumpt -l -w .`, it will format all Go files in the current directory, including `test/_results/*` files.
38-
# We pass only Git-tracked Go files to gofumpt because we don't want to format the test results or get errors from it.
3937
.PHONY: format
4038
format:
41-
git ls-files '*.go' ':!vendor' | xargs gofumpt -l -w
39+
gofumpt -l -w .
4240

4341
.PHONY: lint
4442
lint:

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module github.com/jesseduffield/lazygit
22

33
go 1.25.0
44

5+
// This is necessary to ignore test files when executing gofumpt.
6+
ignore ./test
7+
58
require (
69
dario.cat/mergo v1.0.1
710
github.com/adrg/xdg v0.4.0

pkg/commands/oscommands/copy.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ import (
3535
// destination file exists, all it's contents will be replaced by the contents
3636
// of the source file. The file mode will be copied from the source and
3737
// the copied data is synced/flushed to stable storage.
38-
func CopyFile(src, dst string) (err error) {
38+
func CopyFile(src, dst string) error {
3939
in, err := os.Open(src)
4040
if err != nil {
41-
return //nolint: nakedret
41+
return err
4242
}
4343
defer in.Close()
4444

4545
out, err := os.Create(dst)
4646
if err != nil {
47-
return //nolint: nakedret
47+
return err
4848
}
4949
defer func() {
5050
if e := out.Close(); e != nil {
@@ -54,30 +54,30 @@ func CopyFile(src, dst string) (err error) {
5454

5555
_, err = io.Copy(out, in)
5656
if err != nil {
57-
return //nolint: nakedret
57+
return err
5858
}
5959

6060
err = out.Sync()
6161
if err != nil {
62-
return //nolint: nakedret
62+
return err
6363
}
6464

6565
si, err := os.Stat(src)
6666
if err != nil {
67-
return //nolint: nakedret
67+
return err
6868
}
6969
err = os.Chmod(dst, si.Mode())
7070
if err != nil {
71-
return //nolint: nakedret
71+
return err
7272
}
7373

74-
return //nolint: nakedret
74+
return err
7575
}
7676

7777
// CopyDir recursively copies a directory tree, attempting to preserve permissions.
7878
// Source directory must exist. If destination already exists we'll clobber it.
7979
// Symlinks are ignored and skipped.
80-
func CopyDir(src string, dst string) (err error) {
80+
func CopyDir(src string, dst string) error {
8181
src = filepath.Clean(src)
8282
dst = filepath.Clean(dst)
8383

@@ -91,7 +91,7 @@ func CopyDir(src string, dst string) (err error) {
9191

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

103103
err = os.MkdirAll(dst, si.Mode())
104104
if err != nil {
105-
return //nolint: nakedret
105+
return err
106106
}
107107

108108
entries, err := os.ReadDir(src)
109109
if err != nil {
110-
return //nolint: nakedret
110+
return err
111111
}
112112

113113
for _, entry := range entries {
@@ -117,13 +117,13 @@ func CopyDir(src string, dst string) (err error) {
117117
if entry.IsDir() {
118118
err = CopyDir(srcPath, dstPath)
119119
if err != nil {
120-
return //nolint: nakedret
120+
return err
121121
}
122122
} else {
123123
var info os.FileInfo
124124
info, err = entry.Info()
125125
if err != nil {
126-
return //nolint: nakedret
126+
return err
127127
}
128128

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

134134
err = CopyFile(srcPath, dstPath)
135135
if err != nil {
136-
return //nolint: nakedret
136+
return err
137137
}
138138
}
139139
}
140140

141-
return //nolint: nakedret
141+
return err
142142
}

pkg/gui/presentation/branches_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616
"github.com/xo/terminfo"
1717
)
1818

19-
func makeAtomic(v int32) (result atomic.Int32) {
19+
func makeAtomic(v int32) *atomic.Int32 {
20+
var result atomic.Int32
2021
result.Store(v)
21-
return //nolint: nakedret
22+
return &result
2223
}
2324

2425
func Test_getBranchDisplayStrings(t *testing.T) {
@@ -109,7 +110,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
109110
branch: &models.Branch{
110111
Name: "branch_name",
111112
Recency: "1m",
112-
BehindBaseBranch: makeAtomic(2),
113+
BehindBaseBranch: *makeAtomic(2),
113114
},
114115
itemOperation: types.ItemOperationNone,
115116
fullDescription: false,
@@ -126,7 +127,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
126127
UpstreamRemote: "origin",
127128
AheadForPull: "0",
128129
BehindForPull: "0",
129-
BehindBaseBranch: makeAtomic(2),
130+
BehindBaseBranch: *makeAtomic(2),
130131
},
131132
itemOperation: types.ItemOperationNone,
132133
fullDescription: false,
@@ -143,7 +144,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
143144
UpstreamRemote: "origin",
144145
AheadForPull: "3",
145146
BehindForPull: "5",
146-
BehindBaseBranch: makeAtomic(2),
147+
BehindBaseBranch: *makeAtomic(2),
147148
},
148149
itemOperation: types.ItemOperationNone,
149150
fullDescription: false,
@@ -247,7 +248,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
247248
UpstreamRemote: "origin",
248249
AheadForPull: "3",
249250
BehindForPull: "5",
250-
BehindBaseBranch: makeAtomic(4),
251+
BehindBaseBranch: *makeAtomic(4),
251252
},
252253
itemOperation: types.ItemOperationNone,
253254
fullDescription: false,

0 commit comments

Comments
 (0)