1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-29 22:07:13 +02:00

add some more linters

This commit is contained in:
Jesse Duffield 2022-01-08 15:46:35 +11:00
parent 5d6d894286
commit 18f48a43d5
37 changed files with 104 additions and 60 deletions

View File

@ -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

View File

@ -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)

View File

@ -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) {

View File

@ -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())

View File

@ -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

View File

@ -27,7 +27,7 @@ func NewConfigCommands(
return &ConfigCommands{
Common: common,
gitConfig: gitConfig,
repo: repo,
// repo: repo,
}
}

View File

@ -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,

View File

@ -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

View File

@ -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))

View File

@ -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))

View File

@ -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))
})

View File

@ -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{}

View File

@ -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) {

View File

@ -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(),

View File

@ -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"})

View File

@ -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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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 "" },
}
}

View File

@ -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))
})

View File

@ -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") {

View File

@ -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) {

View File

@ -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)

View File

@ -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)
return gui.afterTagCreate()
},
})
},
@ -636,7 +634,7 @@ func (gui *Gui) handleCreateLightweightTag(commitSha string) error {
if err := gui.Git.Tag.CreateLightweight(tagName, commitSha); err != nil {
return gui.surfaceError(err)
}
return gui.afterTagCreate(tagName)
return gui.afterTagCreate()
},
})
}
@ -666,7 +664,7 @@ func (gui *Gui) handleCreateCommitResetMenu() error {
return gui.createResetMenu(commit.Sha)
}
func (gui *Gui) handleOpenSearchForCommitsPanel(_viewName string) error {
func (gui *Gui) handleOpenSearchForCommitsPanel(string) error {
// we usually lazyload these commits but now that we're searching we need to load them now
if gui.State.Panels.Commits.LimitCommits {
gui.State.Panels.Commits.LimitCommits = false

View File

@ -11,18 +11,18 @@ import (
type credentials chan string
// promptUserForCredential wait for a username, password or passphrase input from the credentials popup
func (gui *Gui) promptUserForCredential(passOrUname oscommands.CredentialName) string {
func (gui *Gui) promptUserForCredential(passOrUname oscommands.CredentialType) string {
gui.credentials = make(chan string)
gui.g.Update(func(g *gocui.Gui) error {
credentialsView := gui.Views.Credentials
switch passOrUname {
case "username":
case oscommands.Username:
credentialsView.Title = gui.Tr.CredentialsUsername
credentialsView.Mask = 0
case "password":
case oscommands.Password:
credentialsView.Title = gui.Tr.CredentialsPassword
credentialsView.Mask = '*'
case "passphrase":
case oscommands.Passphrase:
credentialsView.Title = gui.Tr.CredentialsPassphrase
credentialsView.Mask = '*'
}

View File

@ -144,7 +144,7 @@ func (gui *Gui) GenerateMenuCandidates(commandOutput, filter, valueFormat, label
}
candidates := []commandMenuEntry{}
for _, str := range strings.Split(string(commandOutput), "\n") {
for _, str := range strings.Split(commandOutput, "\n") {
if str == "" {
continue
}
@ -216,6 +216,7 @@ func (gui *Gui) menuPromptFromCommand(prompt config.CustomCommandPrompt, promptR
menuItems := make([]*menuItem, len(candidates))
for i := range candidates {
i := i
menuItems[i] = &menuItem{
displayStrings: []string{candidates[i].label},
onPress: func() error {

View File

@ -56,6 +56,7 @@ func TestGuiGenerateMenuCandidates(t *testing.T) {
}
for _, s := range scenarios {
s := s
t.Run(s.testName, func(t *testing.T) {
s.test(NewDummyGui().GenerateMenuCandidates(s.cmdOut, s.filter, s.valueFormat, s.labelFormat))
})

View File

@ -24,7 +24,7 @@ func TestGetSuggestedRemote(t *testing.T) {
}
func mkRemoteList(names ...string) []*models.Remote {
var result []*models.Remote
result := make([]*models.Remote, 0, len(names))
for _, name := range names {
result = append(result, &models.Remote{Name: name})

View File

@ -648,7 +648,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool,
return cmdErr == nil, gui.surfaceError(cmdErr)
}
func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error {
func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error { //nolint:unparam
gui.logCommand(cmdObj.ToString(), true)
subprocess := cmdObj.GetCmd()

View File

@ -17,7 +17,7 @@ func (gui *Gui) getFromAndReverseArgsForDiff(to string) (string, bool) {
return from, reverse
}
func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int, state *LblPanelState) error {
func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
if !gui.Git.Patch.PatchManager.Active() {
return gui.handleEscapePatchBuildingPanel()
}
@ -59,7 +59,7 @@ func (gui *Gui) handleRefreshPatchBuildingPanel(selectedLineIdx int) error {
gui.Mutexes.LineByLinePanelMutex.Lock()
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
return gui.refreshPatchBuildingPanel(selectedLineIdx, gui.State.Panels.LineByLine)
return gui.refreshPatchBuildingPanel(selectedLineIdx)
}
func (gui *Gui) handleToggleSelectionForPatch() error {

View File

@ -9,7 +9,7 @@ import (
)
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, status patch.PatchStatus) string {
colour := theme.DefaultTextColor
var colour style.TextStyle
if diffName == name {
colour = theme.DiffTerminalColor
} else {
@ -18,6 +18,8 @@ func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFi
colour = style.FgGreen
case patch.PART:
colour = style.FgYellow
case patch.UNSELECTED:
colour = theme.DefaultTextColor
}
}

View File

@ -121,6 +121,7 @@ func (cell *Cell) setLeft(style style.TextStyle) *Cell {
return cell
}
//nolint:unparam
func (cell *Cell) setRight(style style.TextStyle, override bool) *Cell {
cell.right = true
if cell.rightStyle == nil || override {

View File

@ -59,6 +59,8 @@ func (gui *Gui) genericMergeCommand(command string) error {
commandType = "merge"
case enums.REBASE_MODE_REBASING:
commandType = "rebase"
default:
// shouldn't be possible to land here
}
// we should end up with a command like 'git merge --continue'

View File

@ -110,6 +110,8 @@ func (gui *Gui) reflogUndo() error {
EnvVars: undoEnvVars,
WaitingStatus: undoingStatus,
})
case CURRENT_REBASE:
// do nothing
}
gui.Log.Error("didn't match on the user action when trying to undo")
@ -146,6 +148,8 @@ func (gui *Gui) reflogRedo() error {
EnvVars: redoEnvVars,
WaitingStatus: redoingStatus,
})
case CURRENT_REBASE:
// do nothing
}
gui.Log.Error("didn't match on the user action when trying to redo")

View File

@ -114,9 +114,9 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
wg.Add(1)
func() {
if options.mode == ASYNC {
go utils.Safe(func() { _ = gui.refreshCommits() })
go utils.Safe(func() { gui.refreshCommits() })
} else {
_ = gui.refreshCommits()
gui.refreshCommits()
}
wg.Done()
}()

View File

@ -121,10 +121,8 @@ func (u *Updater) checkForNewUpdate() (string, error) {
return "", errors.New(errMessage)
}
rawUrl, err := u.getBinaryUrl(newVersion)
if err != nil {
return "", err
}
rawUrl := u.getBinaryUrl(newVersion)
u.Log.Info("Checking for resource at url " + rawUrl)
if !u.verifyResourceFound(rawUrl) {
errMessage := utils.ResolvePlaceholderString(
@ -224,7 +222,7 @@ func (u *Updater) zipExtension() string {
}
// example: https://github.com/jesseduffield/lazygit/releases/download/v0.1.73/lazygit_0.1.73_Darwin_x86_64.tar.gz
func (u *Updater) getBinaryUrl(newVersion string) (string, error) {
func (u *Updater) getBinaryUrl(newVersion string) string {
url := fmt.Sprintf(
"%s/releases/download/%s/lazygit_%s_%s_%s.%s",
constants.Links.RepoUrl,
@ -235,7 +233,7 @@ func (u *Updater) getBinaryUrl(newVersion string) (string, error) {
u.zipExtension(),
)
u.Log.Info("Url for latest release is " + url)
return url, nil
return url
}
// Update downloads the latest binary and replaces the current binary with it
@ -249,10 +247,7 @@ func (u *Updater) Update(newVersion string, onFinish func(error) error) {
}
func (u *Updater) update(newVersion string) error {
rawUrl, err := u.getBinaryUrl(newVersion)
if err != nil {
return err
}
rawUrl := u.getBinaryUrl(newVersion)
u.Log.Info("Updating with url " + rawUrl)
return u.downloadAndInstall(rawUrl)
}

View File

@ -85,6 +85,7 @@ func TestNextIndex(t *testing.T) {
}
for _, s := range scenarios {
s := s
t.Run(s.testName, func(t *testing.T) {
assert.EqualValues(t, s.expected, NextIndex(s.list, s.element))
})
@ -128,6 +129,7 @@ func TestPrevIndex(t *testing.T) {
}
for _, s := range scenarios {
s := s
t.Run(s.testName, func(t *testing.T) {
assert.EqualValues(t, s.expected, PrevIndex(s.list, s.element))
})
@ -160,6 +162,7 @@ func TestEscapeSpecialChars(t *testing.T) {
}
for _, s := range scenarios {
s := s
t.Run(s.testName, func(t *testing.T) {
assert.EqualValues(t, s.expected, EscapeSpecialChars(s.input))
})