mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-08-24 10:13:41 -05:00
Fix makeAtomic in branches_test
When replacing the naked return with a `return result`, the linter starts to complain about "return copies lock value: sync/atomic.Int32 contains sync/atomic.noCopy". I suspect this is also a problem when using a naked return, and the linter just doesn't catch it in that case. Either way, it's better to use a pointer to ensure that the atomic is not copied. Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
This commit is contained in:
committed by
Stefan Haller
co-authored by
Stefan Haller
parent
65c27dd8ce
commit
beb05d4a61
@@ -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) {
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user