summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-08 15:46:35 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-01-09 14:09:53 +1100
commit18f48a43d5401af97dae18aab07238146b7d587b (patch)
tree5f220bac5ac7210ee5f30c80cba6d396a8f0b18f /pkg
parent5d6d8942862428afb72bc45b562af10ceac6e0a3 (diff)
add some more linters
Diffstat (limited to 'pkg')
-rw-r--r--pkg/app/app.go8
-rw-r--r--pkg/app/app_test.go1
-rw-r--r--pkg/app/logging.go5
-rw-r--r--pkg/commands/git_commands/branch_test.go4
-rw-r--r--pkg/commands/git_commands/commit_test.go3
-rw-r--r--pkg/commands/git_commands/config.go2
-rw-r--r--pkg/commands/git_commands/rebase_test.go3
-rw-r--r--pkg/commands/git_commands/stash_test.go1
-rw-r--r--pkg/commands/git_commands/sync_test.go1
-rw-r--r--pkg/commands/git_commands/working_tree_test.go10
-rw-r--r--pkg/commands/git_test.go4
-rw-r--r--pkg/commands/hosting_service/hosting_service_test.go2
-rw-r--r--pkg/commands/loaders/commits.go9
-rw-r--r--pkg/commands/loaders/commits_test.go1
-rw-r--r--pkg/commands/loaders/files_test.go1
-rw-r--r--pkg/commands/loaders/stash_test.go1
-rw-r--r--pkg/commands/oscommands/cmd_obj_runner.go8
-rw-r--r--pkg/commands/oscommands/exec_live.go20
-rw-r--r--pkg/commands/oscommands/gui_io.go6
-rw-r--r--pkg/commands/oscommands/os_test.go1
-rw-r--r--pkg/commands/patch/patch_modifier.go2
-rw-r--r--pkg/commands/patch/patch_modifier_test.go2
-rw-r--r--pkg/commands/patch/patch_parser.go4
-rw-r--r--pkg/gui/commits_panel.go12
-rw-r--r--pkg/gui/credentials_panel.go8
-rw-r--r--pkg/gui/custom_commands.go3
-rw-r--r--pkg/gui/custom_commands_test.go1
-rw-r--r--pkg/gui/files_panel_test.go2
-rw-r--r--pkg/gui/gui.go2
-rw-r--r--pkg/gui/patch_building_panel.go4
-rw-r--r--pkg/gui/presentation/commit_files.go4
-rw-r--r--pkg/gui/presentation/graph/cell.go1
-rw-r--r--pkg/gui/rebase_options_panel.go2
-rw-r--r--pkg/gui/undoing.go4
-rw-r--r--pkg/gui/view_helpers.go4
-rw-r--r--pkg/updates/updates.go15
-rw-r--r--pkg/utils/slice_test.go3
37 files changed, 104 insertions, 60 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index ad3246ace..c3df367ec 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -42,7 +42,7 @@ type errorMapping struct {
newError string
}
-func newProductionLogger(config config.AppConfigurer) *logrus.Logger {
+func newProductionLogger() *logrus.Logger {
log := logrus.New()
log.Out = ioutil.Discard
log.SetLevel(logrus.ErrorLevel)
@@ -58,7 +58,7 @@ func getLogLevel() logrus.Level {
return level
}
-func newDevelopmentLogger(configurer config.AppConfigurer) *logrus.Logger {
+func newDevelopmentLogger() *logrus.Logger {
logger := logrus.New()
logger.SetLevel(getLogLevel())
logPath, err := config.LogPath()
@@ -76,9 +76,9 @@ func newDevelopmentLogger(configurer config.AppConfigurer) *logrus.Logger {
func newLogger(config config.AppConfigurer) *logrus.Entry {
var log *logrus.Logger
if config.GetDebug() || os.Getenv("DEBUG") == "TRUE" {
- log = newDevelopmentLogger(config)
+ log = newDevelopmentLogger()
} else {
- log = newProductionLogger(config)
+ log = newProductionLogger()
}
// highly recommended: tail -f development.log | humanlog
diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go
index 1ec46f0f7..c2cd0c8c0 100644
--- a/pkg/app/app_test.go
+++ b/pkg/app/app_test.go
@@ -36,6 +36,7 @@ func TestIsGitVersionValid(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.versionStr, func(t *testing.T) {
result := isGitVersionValid(s.versionStr)
assert.Equal(t, result, s.expectedResult)
diff --git a/pkg/app/logging.go b/pkg/app/logging.go
index 40d58ad62..7df0bb0c2 100644
--- a/pkg/app/logging.go
+++ b/pkg/app/logging.go
@@ -4,10 +4,11 @@
package app
import (
- "github.com/aybabtme/humanlog"
- "github.com/jesseduffield/lazygit/pkg/secureexec"
"log"
"os"
+
+ "github.com/aybabtme/humanlog"
+ "github.com/jesseduffield/lazygit/pkg/secureexec"
)
func TailLogsForPlatform(logFilePath string, opts *humanlog.HandlerOptions) {
diff --git a/pkg/commands/git_commands/branch_test.go b/pkg/commands/git_commands/branch_test.go
index 447ccaaff..552165695 100644
--- a/pkg/commands/git_commands/branch_test.go
+++ b/pkg/commands/git_commands/branch_test.go
@@ -46,6 +46,7 @@ func TestBranchGetCommitDifferences(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := NewBranchCommandsWithRunner(s.runner)
pushables, pullables := instance.GetCommitDifferences("HEAD", "@{u}")
@@ -93,6 +94,7 @@ func TestBranchDeleteBranch(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := NewBranchCommandsWithRunner(s.runner)
@@ -139,6 +141,7 @@ func TestBranchCheckout(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := NewBranchCommandsWithRunner(s.runner)
s.test(instance.Checkout("test", CheckoutOptions{Force: s.force}))
@@ -218,6 +221,7 @@ func TestBranchCurrentBranchName(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := NewBranchCommandsWithRunner(s.runner)
s.test(instance.CurrentBranchName())
diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go
index 6408f440a..08ee7e5cc 100644
--- a/pkg/commands/git_commands/commit_test.go
+++ b/pkg/commands/git_commands/commit_test.go
@@ -75,6 +75,7 @@ func TestCommitCommitObj(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig()
userConfig.Git.Commit.SignOff = s.configSignoff
@@ -109,6 +110,7 @@ func TestCommitCreateFixupCommit(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildCommitCommands(commonDeps{runner: s.runner})
s.test(instance.CreateFixupCommit(s.sha))
@@ -147,6 +149,7 @@ func TestCommitShowCmdObj(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig()
userConfig.Git.DiffContextSize = s.contextSize
diff --git a/pkg/commands/git_commands/config.go b/pkg/commands/git_commands/config.go
index e22333541..76c8b5590 100644
--- a/pkg/commands/git_commands/config.go
+++ b/pkg/commands/git_commands/config.go
@@ -27,7 +27,7 @@ func NewConfigCommands(
return &ConfigCommands{
Common: common,
gitConfig: gitConfig,
- repo: repo,
+ // repo: repo,
}
}
diff --git a/pkg/commands/git_commands/rebase_test.go b/pkg/commands/git_commands/rebase_test.go
index e4731ad83..56df77a86 100644
--- a/pkg/commands/git_commands/rebase_test.go
+++ b/pkg/commands/git_commands/rebase_test.go
@@ -42,6 +42,7 @@ func TestRebaseRebaseBranch(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildRebaseCommands(commonDeps{runner: s.runner})
s.test(instance.RebaseBranch(s.arg))
@@ -62,6 +63,7 @@ func TestRebaseSkipEditorCommand(t *testing.T) {
`^GIT_EDITOR=.*$`,
"^LAZYGIT_CLIENT_COMMAND=EXIT_IMMEDIATELY$",
} {
+ regexStr := regexStr
foundMatch := utils.IncludesStringFunc(envVars, func(envVar string) bool {
return regexp.MustCompile(regexStr).MatchString(envVar)
})
@@ -135,6 +137,7 @@ func TestRebaseDiscardOldFileChanges(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildRebaseCommands(commonDeps{
runner: s.runner,
diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go
index f9f2428e0..b41f7815b 100644
--- a/pkg/commands/git_commands/stash_test.go
+++ b/pkg/commands/git_commands/stash_test.go
@@ -68,6 +68,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig()
userConfig.Git.DiffContextSize = s.contextSize
diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go
index a1eae5dbb..9c33381fe 100644
--- a/pkg/commands/git_commands/sync_test.go
+++ b/pkg/commands/git_commands/sync_test.go
@@ -85,6 +85,7 @@ func TestSyncPush(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildSyncCommands(commonDeps{})
s.test(instance.PushCmdObj(s.opts))
diff --git a/pkg/commands/git_commands/working_tree_test.go b/pkg/commands/git_commands/working_tree_test.go
index a6d2345e9..ef3aedcf9 100644
--- a/pkg/commands/git_commands/working_tree_test.go
+++ b/pkg/commands/git_commands/working_tree_test.go
@@ -53,6 +53,7 @@ func TestWorkingTreeUnstageFile(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.UnStageFile([]string{"test.txt"}, s.reset))
@@ -181,6 +182,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, removeFile: s.removeFile})
err := instance.DiscardAllFileChanges(s.file)
@@ -296,6 +298,7 @@ func TestWorkingTreeDiff(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig()
userConfig.Git.DiffContextSize = s.contextSize
@@ -345,6 +348,7 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig()
userConfig.Git.DiffContextSize = s.contextSize
@@ -392,6 +396,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
@@ -445,6 +450,7 @@ func TestWorkingTreeApplyPatch(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.ApplyPatch("test", "cached"))
@@ -474,6 +480,7 @@ func TestWorkingTreeDiscardUnstagedFileChanges(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.DiscardUnstagedFileChanges(s.file))
@@ -501,6 +508,7 @@ func TestWorkingTreeDiscardAnyUnstagedFileChanges(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.DiscardAnyUnstagedFileChanges())
@@ -528,6 +536,7 @@ func TestWorkingTreeRemoveUntrackedFiles(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.RemoveUntrackedFiles())
@@ -557,6 +566,7 @@ func TestWorkingTreeResetHard(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.ResetHard(s.ref))
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index b730bf6dc..684696a8c 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -104,6 +104,7 @@ func TestNavigateToRepoRootDirectory(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
s.test(navigateToRepoRootDirectory(s.stat, s.chdir))
})
@@ -159,6 +160,7 @@ func TestSetupRepository(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
s.test(setupRepository(s.openGitRepository, s.errorStr))
})
@@ -206,6 +208,7 @@ func TestNewGitCommand(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
s.setup()
s.test(NewGitCommand(utils.NewDummyCommon(), oscommands.NewDummyOSCommand(), git_config.NewFakeGitConfig(nil)))
@@ -282,6 +285,7 @@ func TestFindDotGitDir(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
s.test(findDotGitDir(s.stat, s.readFile))
})
diff --git a/pkg/commands/hosting_service/hosting_service_test.go b/pkg/commands/hosting_service/hosting_service_test.go
index ab7a2b402..f762135c3 100644
--- a/pkg/commands/hosting_service/hosting_service_test.go
+++ b/pkg/commands/hosting_service/hosting_service_test.go
@@ -56,6 +56,7 @@ func TestGetRepoInfoFromURL(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
result, err := s.serviceDefinition.getRepoInfoFromURL(s.repoURL)
assert.NoError(t, err)
@@ -222,6 +223,7 @@ func TestGetPullRequestURL(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
tr := i18n.EnglishTranslationSet()
log := &test.FakeFieldLogger{}
diff --git a/pkg/commands/loaders/commits.go b/pkg/commands/loaders/commits.go
index cc2442c96..ea54a4e76 100644
--- a/pkg/commands/loaders/commits.go
+++ b/pkg/commands/loaders/commits.go
@@ -274,10 +274,7 @@ func (self *CommitLoader) getNormalRebasingCommits() ([]*models.Commit, error) {
return err
}
content := string(bytesContent)
- commit, err := self.commitFromPatch(content)
- if err != nil {
- return err
- }
+ commit := self.commitFromPatch(content)
commits = append([]*models.Commit{commit}, commits...)
return nil
})
@@ -334,7 +331,7 @@ func (self *CommitLoader) getInteractiveRebasingCommits() ([]*models.Commit, err
// From: Lazygit Tester <test@example.com>
// Date: Wed, 5 Dec 2018 21:03:23 +1100
// Subject: second commit on master
-func (self *CommitLoader) commitFromPatch(content string) (*models.Commit, error) {
+func (self *CommitLoader) commitFromPatch(content string) *models.Commit {
lines := strings.Split(content, "\n")
sha := strings.Split(lines[0], " ")[1]
name := strings.TrimPrefix(lines[3], "Subject: ")
@@ -342,7 +339,7 @@ func (self *CommitLoader) commitFromPatch(content string) (*models.Commit, error
Sha: sha,
Name: name,
Status: "rebasing",
- }, nil
+ }
}
func (self *CommitLoader) setCommitMergedStatuses(refName string, commits []*models.Commit) ([]*models.Commit, error) {
diff --git a/pkg/commands/loaders/commits_test.go b/pkg/commands/loaders/commits_test.go
index 5491fb4a5..9eda80708 100644
--- a/pkg/commands/loaders/commits_test.go
+++ b/pkg/commands/loaders/commits_test.go
@@ -186,6 +186,7 @@ func TestGetCommits(t *testing.T) {
}
for _, scenario := range scenarios {
+ scenario := scenario
t.Run(scenario.testName, func(t *testing.T) {
builder := &CommitLoader{
Common: utils.NewDummyCommon(),
diff --git a/pkg/commands/loaders/files_test.go b/pkg/commands/loaders/files_test.go
index 2f1b12704..825164e01 100644
--- a/pkg/commands/loaders/files_test.go
+++ b/pkg/commands/loaders/files_test.go
@@ -186,6 +186,7 @@ func TestFileGetStatusFiles(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
gitConfig := git_config.NewFakeGitConfig(map[string]string{"status.showUntrackedFiles": "yes"})
diff --git a/pkg/commands/loaders/stash_test.go b/pkg/commands/loaders/stash_test.go
index 31c83792f..e7999e861 100644
--- a/pkg/commands/loaders/stash_test.go
+++ b/pkg/commands/loaders/stash_test.go
@@ -48,6 +48,7 @@ func TestGetStashEntries(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
diff --git a/pkg/commands/oscommands/cmd_obj_runner.go b/pkg/commands/oscommands/cmd_obj_runner.go
index 816e56ad6..bbd3c85cc 100644
--- a/pkg/commands/oscommands/cmd_obj_runner.go
+++ b/pkg/commands/oscommands/cmd_obj_runner.go
@@ -26,11 +26,13 @@ func (self *cmdObjRunner) runWithCredentialHandling(cmdObj ICmdObj) error {
case PROMPT:
return self.RunAndDetectCredentialRequest(cmdObj, self.guiIO.promptForCredentialFn)
case FAIL:
- return self.RunAndDetectCredentialRequest(cmdObj, func(CredentialName) string { return "\n" })
+ return self.RunAndDetectCredentialRequest(cmdObj, func(CredentialType) string { return "\n" })
+ case NONE:
+ // we should never land here
+ return errors.New("runWithCredentialHandling called but cmdObj does not have a a credential strategy")
}
- // we should never land here
- return errors.New("runWithCredentialHandling called but cmdObj does not have a a credential strategy")
+ return errors.New("unexpected credential strategy")
}
func (self *cmdObjRunner) Run(cmdObj ICmdObj) error {
diff --git a/pkg/commands/oscommands/exec_live.go b/pkg/commands/oscommands/exec_live.go
index 3526cdbd2..efddf355e 100644
--- a/pkg/commands/oscommands/exec_live.go
+++ b/pkg/commands/oscommands/exec_live.go
@@ -13,27 +13,27 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
-type CredentialName string
+type CredentialType int
const (
- Password CredentialName = "password"
- Username = "username"
- Passphrase = "passphrase"
+ Password CredentialType = iota
+ Username
+ Passphrase
)
// RunAndDetectCredentialRequest detect a username / password / passphrase question in a command
// promptUserForCredential is a function that gets executed when this function detect you need to fillin a password or passphrase
// The promptUserForCredential argument will be "username", "password" or "passphrase" and expects the user's password/passphrase or username back
-func (self *cmdObjRunner) RunAndDetectCredentialRequest(cmdObj ICmdObj, promptUserForCredential func(CredentialName) string) error {
+func (self *cmdObjRunner) RunAndDetectCredentialRequest(cmdObj ICmdObj, promptUserForCredential func(CredentialType) string) error {
ttyText := ""
err := self.RunCommandWithOutputLive(cmdObj, func(word string) string {
ttyText = ttyText + " " + word
- prompts := map[string]CredentialName{
- `.+'s password:`: "password",
- `Password\s*for\s*'.+':`: "password",
- `Username\s*for\s*'.+':`: "username",
- `Enter\s*passphrase\s*for\s*key\s*'.+':`: "passphrase",
+ prompts := map[string]CredentialType{
+ `.+'s password:`: Password,
+ `Password\s*for\s*'.+':`: Password,
+ `Username\s*for\s*'.+':`: Username,
+ `Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
}
for pattern, askFor := range prompts {
diff --git a/pkg/commands/oscommands/gui_io.go b/pkg/commands/oscommands/gui_io.go
index 5a174d46c..33a02874b 100644
--- a/pkg/commands/oscommands/gui_io.go
+++ b/pkg/commands/oscommands/gui_io.go
@@ -27,10 +27,10 @@ type guiIO struct {
// this allows us to request info from the user like username/password, in the event
// that a command requests it.
// the 'credential' arg is something like 'username' or 'password'
- promptForCredentialFn func(credential CredentialName) string
+ promptForCredentialFn func(credential CredentialType) string
}
-func NewGuiIO(log *logrus.Entry, logCommandFn func(string, bool), newCmdWriterFn func() io.Writer, promptForCredentialFn func(CredentialName) string) *guiIO {
+func NewGuiIO(log *logrus.Entry, logCommandFn func(string, bool), newCmdWriterFn func() io.Writer, promptForCredentialFn func(CredentialType) string) *guiIO {
return &guiIO{
log: log,
logCommandFn: logCommandFn,
@@ -44,6 +44,6 @@ func NewNullGuiIO(log *logrus.Entry) *guiIO {
log: log,
logCommandFn: func(string, bool) {},
newCmdWriterFn: func() io.Writer { return ioutil.Discard },
- promptForCredentialFn: func(CredentialName) string { return "" },
+ promptForCredentialFn: func(CredentialType) string { return "" },
}
}
diff --git a/pkg/commands/oscommands/os_test.go b/pkg/commands/oscommands/os_test.go
index b5d8879b9..efda5a3a1 100644
--- a/pkg/commands/oscommands/os_test.go
+++ b/pkg/commands/oscommands/os_test.go
@@ -190,6 +190,7 @@ func TestOSCommandCreateTempFile(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
s.test(NewDummyOSCommand().CreateTempFile(s.filename, s.content))
})
diff --git a/pkg/commands/patch/patch_modifier.go b/pkg/commands/patch/patch_modifier.go
index 3ab13931b..2109ad1f0 100644
--- a/pkg/commands/patch/patch_modifier.go
+++ b/pkg/commands/patch/patch_modifier.go
@@ -22,7 +22,7 @@ func GetHeaderFromDiff(diff string) string {
func GetHunksFromDiff(diff string) []*PatchHunk {
hunks := []*PatchHunk{}
firstLineIdx := -1
- var hunkLines []string
+ var hunkLines []string //nolint:prealloc
pastDiffHeader := false
for lineIdx, line := range strings.SplitAfter(diff, "\n") {
diff --git a/pkg/commands/patch/patch_modifier_test.go b/pkg/commands/patch/patch_modifier_test.go
index 8b866019b..ec79cbe32 100644
--- a/pkg/commands/patch/patch_modifier_test.go
+++ b/pkg/commands/patch/patch_modifier_test.go
@@ -511,6 +511,7 @@ func TestModifyPatchForRange(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
result := ModifiedPatchForRange(nil, s.filename, s.diffText, s.firstLineIndex, s.lastLineIndex, s.reverse, false)
if !assert.Equal(t, s.expected, result) {
@@ -538,6 +539,7 @@ func TestLineNumberOfLine(t *testing.T) {
}
for _, s := range scenarios {
+ s := s
t.Run(s.testName, func(t *testing.T) {
result := s.hunk.LineNumberOfLine(s.idx)
if !assert.Equal(t, s.expected, result) {
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go
index 1fefe0748..c2be120c9 100644
--- a/pkg/commands/patch/patch_parser.go
+++ b/pkg/commands/patch/patch_parser.go
@@ -98,7 +98,7 @@ func (l *PatchLine) render(selected bool, included bool) string {
return coloredString(style.FgCyan, match[1], selected, included) + coloredString(theme.DefaultTextColor, match[2], selected, false)
}
- textStyle := theme.DefaultTextColor
+ var textStyle style.TextStyle
switch l.Kind {
case PATCH_HEADER:
textStyle = textStyle.SetBold()
@@ -108,6 +108,8 @@ func (l *PatchLine) render(selected bool, included bool) string {
textStyle = style.FgRed
case COMMIT_SHA:
textStyle = style.FgYellow
+ default:
+ textStyle = theme.DefaultTextColor
}
return coloredString(textStyle, content, selected, included)
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 3817e9e47..fcc49d839 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -79,7 +79,7 @@ func (gui *Gui) refreshReflogCommitsConsideringStartup() {
// whenever we change commits, we should update branches because the upstream/downstream
// counts can change. Whenever we change branches we should probably also change commits
// e.g. in the case of switching branches.
-func (gui *Gui) refreshCommits() error {
+func (gui *Gui) refreshCommits() {
wg := sync.WaitGroup{}
wg.Add(2)
@@ -110,8 +110,6 @@ func (gui *Gui) refreshCommits() error {
})
wg.Wait()
-
- return nil
}
func (gui *Gui) refreshCommitsWithLimit() error {
@@ -605,7 +603,7 @@ func (gui *Gui) createTagMenu(commitSha string) error {
return gui.createMenu(gui.Tr.TagMenuTitle, items, createMenuOptions{showCancel: true})
}
-func (gui *Gui) afterTagCreate(tagName string) error {
+func (gui *Gui) afterTagCreate() error {
gui.State.Panels.Tags.SelectedLineIdx = 0 // Set to the top
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}})
}
@@ -621,7 +619,7 @@ func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error {
if err := gui.Git.Tag.CreateAnnotated(tagName, commitSha, msg); err != nil {
return gui.surfaceError(err)
}
- return gui.afterTagCreate(tagName)
+ ret