Skip to content

Commit 96edb8a

Browse files
authored
Merge branch 'master' into fix/skip-recent-repositories
2 parents b005730 + 36388e5 commit 96edb8a

File tree

97 files changed

+609
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+609
-424
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ jobs:
169169
with:
170170
go-version: 1.24.x
171171
- name: Lint
172-
uses: golangci/golangci-lint-action@v6.5.0
172+
uses: golangci/golangci-lint-action@v8
173173
with:
174-
version: v1.64.6
174+
version: v2.2.1
175175
- name: errors
176176
run: golangci-lint run
177177
if: ${{ failure() }}

.golangci.yml

Lines changed: 108 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,114 @@
1+
version: "2"
2+
run:
3+
go: "1.24"
14
linters:
25
enable:
3-
- gofumpt
4-
- thelper
5-
- goimports
6-
- tparallel
7-
- wastedassign
8-
- unparam
9-
- prealloc
10-
- unconvert
6+
- copyloopvar
7+
- errorlint
118
- exhaustive
9+
- intrange
1210
- makezero
1311
- nakedret
14-
- copyloopvar
15-
fast: false
16-
17-
linters-settings:
18-
copyloopvar:
19-
# Check all assigning the loop variable to another variable.
20-
# Default: false
21-
# If true, an assignment like `a := x` will be detected as an error.
22-
check-alias: true
23-
exhaustive:
24-
default-signifies-exhaustive: true
25-
staticcheck:
26-
# SA1019 is for checking that we're not using fields marked as deprecated
27-
# in a comment. It decides this in a loose way so I'm silencing it. Also because
28-
# it's tripping on our own structs.
29-
checks: ["all", "-SA1019"]
30-
nakedret:
31-
# the gods will judge me but I just don't like naked returns at all
32-
max-func-lines: 0
12+
- nolintlint
13+
- prealloc
14+
- revive
15+
- thelper
16+
- tparallel
17+
- unconvert
18+
- unparam
19+
- wastedassign
20+
settings:
21+
copyloopvar:
22+
check-alias: true
23+
exhaustive:
24+
default-signifies-exhaustive: true
25+
nakedret:
26+
# the gods will judge me but I just don't like naked returns at all
27+
max-func-lines: 0
28+
staticcheck:
29+
checks:
30+
- all
3331

34-
run:
35-
go: "1.24"
36-
timeout: 10m
32+
# SA1019 is for checking that we're not using fields marked as
33+
# deprecated in a comment. It decides this in a loose way so I'm
34+
# silencing it. Also because it's tripping on our own structs.
35+
- -SA1019
36+
37+
# ST1003 complains about names like remoteUrl or itemId (should be
38+
# remoteURL and itemID). While I like these suggestions, it also
39+
# complains about enum constants that are all caps, and we use these and
40+
# I like them, and also about camelCase identifiers that contain an
41+
# underscore, which we also use in a few places. Since it can't be
42+
# configured to ignore specific cases, and I don't want to use nolint
43+
# comments in the code, we have to disable it altogether.
44+
- -ST1003 # Poorly chosen identifier
45+
46+
# Probably a good idea, but we first have to review our error reporting
47+
# strategy to be able to use it everywhere.
48+
- -ST1005 # Error strings should not be capitalized
49+
50+
# Many of our classes use self as a receiver name, and we think that's fine.
51+
- -ST1006 # Use of self or this as receiver name
52+
53+
# De Morgan's law suggests to replace `!(a && b)` with `!a || !b`; but
54+
# sometimes I find one more readable than the other, so I want to decide
55+
# that myself.
56+
- -QF1001 # De Morgan's law
57+
58+
# QF1003 is about using a tagged switch instead of an if-else chain. In
59+
# many cases this is a useful suggestion; however, sometimes the change
60+
# is only possible by adding a default case to the switch (when there
61+
# was no `else` block in the original code), in which case I don't find
62+
# it to be an improvement.
63+
- -QF1003 # Could replace with tagged switch
64+
65+
# We need to review our use of embedded fields. I suspect that in some
66+
# cases the fix is not to remove the selector for the embedded field,
67+
# but to turn the embedded field into a named field.
68+
- -QF1008 # Could remove embedded field from selector
69+
70+
# The following checks are all disabled by default in golangci-lint, but
71+
# we disable them again explicitly here to make it easier to keep this
72+
# list in sync with the gopls config in .vscode/settings.json.
73+
- -ST1000, # At least one file in a package should have a package comment
74+
- -ST1020, # The documentation of an exported function should start with the function's name
75+
- -ST1021, # The documentation of an exported type should start with type's name
76+
- -ST1022, # The documentation of an exported variable or constant should start with variable's name
77+
78+
dot-import-whitelist:
79+
- github.com/jesseduffield/lazygit/pkg/integration/components
80+
revive:
81+
severity: warning
82+
rules:
83+
- name: atomic
84+
- name: context-as-argument
85+
- name: context-keys-type
86+
- name: error-naming
87+
- name: var-declaration
88+
- name: package-comments
89+
- name: range
90+
- name: time-naming
91+
- name: indent-error-flow
92+
- name: errorf
93+
- name: superfluous-else
94+
exclusions:
95+
generated: lax
96+
presets:
97+
- comments
98+
- common-false-positives
99+
- legacy
100+
- std-error-handling
101+
paths:
102+
- third_party$
103+
- builtin$
104+
- examples$
105+
formatters:
106+
enable:
107+
- gofumpt
108+
- goimports
109+
exclusions:
110+
generated: lax
111+
paths:
112+
- third_party$
113+
- builtin$
114+
- examples$

.vscode/settings.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
{
22
"gopls": {
33
"formatting.gofumpt": true,
4+
"ui.diagnostic.staticcheck": true,
5+
"ui.diagnostic.analyses": {
6+
// This list must match the one in .golangci.yml
7+
"SA1019": false,
8+
"ST1003": false,
9+
"ST1005": false,
10+
"ST1006": false,
11+
"QF1001": false,
12+
"QF1003": false,
13+
"QF1008": false,
14+
"ST1000": false,
15+
"ST1020": false,
16+
"ST1021": false,
17+
"ST1022": false,
18+
// Dot imports; this warning is enabled in .golangci.yml, but with an
19+
// extra dot-import-whitelist config. Because I couldn't figure out how to
20+
// specify that extra config for gopls, I'm disabling the check altogether
21+
// here.
22+
"ST1001": false,
23+
},
424
},
25+
"go.alternateTools": {
26+
"golangci-lint-v2": "${workspaceFolder}/.bin/golangci-lint",
27+
},
28+
"go.lintTool": "golangci-lint-v2",
529
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ format:
4040

4141
.PHONY: lint
4242
lint:
43-
golangci-lint run
43+
./scripts/lint.sh
4444

4545
# For more details about integration test, see https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md.
4646
.PHONY: integration-test-tui

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require (
4747
github.com/ProtonMail/go-crypto v1.1.6 // indirect
4848
github.com/bahlo/generic-list-go v0.2.0 // indirect
4949
github.com/buger/jsonparser v1.1.1 // indirect
50-
github.com/cloudflare/circl v1.6.0 // indirect
50+
github.com/cloudflare/circl v1.6.1 // indirect
5151
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
5252
github.com/davecgh/go-spew v1.1.1 // indirect
5353
github.com/emirpasic/gods v1.18.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
6565
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
6666
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
6767
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
68-
github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk=
69-
github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
68+
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
69+
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
7070
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:tuijfIjZyjZaHq9xDUh0tNitwXshJpbLkqMOJv4H3do=
7171
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc=
7272
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=

pkg/app/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ func newLogger(cfg config.AppConfigurer) *logrus.Entry {
8686
log.Fatal(err)
8787
}
8888
return logs.NewDevelopmentLogger(logPath)
89-
} else {
90-
return logs.NewProductionLogger()
9189
}
90+
91+
return logs.NewProductionLogger()
9292
}
9393

9494
// NewApp bootstrap a new application

pkg/app/daemon/rebase.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ type TodoLine struct {
2121
func (self *TodoLine) ToString() string {
2222
if self.Action == "break" {
2323
return self.Action + "\n"
24-
} else {
25-
return self.Action + " " + self.Commit.Hash() + " " + self.Commit.Name + "\n"
2624
}
25+
return self.Action + " " + self.Commit.Hash() + " " + self.Commit.Name + "\n"
2726
}
2827

2928
func TodoLinesToString(todoLines []TodoLine) string {

pkg/commands/git_cmd_obj_runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (self *gitCmdObjRunner) Run(cmdObj *oscommands.CmdObj) error {
2828
func (self *gitCmdObjRunner) RunWithOutput(cmdObj *oscommands.CmdObj) (string, error) {
2929
var output string
3030
var err error
31-
for i := 0; i < RetryCount; i++ {
31+
for range RetryCount {
3232
newCmdObj := cmdObj.Clone()
3333
output, err = self.innerRunner.RunWithOutput(newCmdObj)
3434

@@ -47,7 +47,7 @@ func (self *gitCmdObjRunner) RunWithOutput(cmdObj *oscommands.CmdObj) (string, e
4747
func (self *gitCmdObjRunner) RunWithOutputs(cmdObj *oscommands.CmdObj) (string, string, error) {
4848
var stdout, stderr string
4949
var err error
50-
for i := 0; i < RetryCount; i++ {
50+
for range RetryCount {
5151
newCmdObj := cmdObj.Clone()
5252
stdout, stderr, err = self.innerRunner.RunWithOutputs(newCmdObj)
5353

pkg/commands/git_commands/branch.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,18 @@ func (self *BranchCommands) CurrentBranchInfo() (BranchInfo, error) {
102102
}, nil
103103
}
104104

105-
// CurrentBranchName get name of current branch
105+
// CurrentBranchName get name of current branch. Returns empty string if HEAD is detached.
106106
func (self *BranchCommands) CurrentBranchName() (string, error) {
107-
cmdArgs := NewGitCmd("rev-parse").
108-
Arg("--abbrev-ref").
109-
Arg("--verify").
110-
Arg("HEAD").
107+
cmdArgs := NewGitCmd("branch").
108+
Arg("--show-current").
111109
ToArgv()
112110

113111
output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
114-
if err == nil {
115-
return strings.TrimSpace(output), nil
112+
if err != nil {
113+
return "", err
116114
}
117-
return "", err
115+
116+
return strings.TrimSpace(output), nil
118117
}
119118

120119
// LocalDelete delete branch locally

0 commit comments

Comments
 (0)