mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
add some more linters
This commit is contained in:
@ -42,7 +42,7 @@ type errorMapping struct {
|
|||||||
newError string
|
newError string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newProductionLogger(config config.AppConfigurer) *logrus.Logger {
|
func newProductionLogger() *logrus.Logger {
|
||||||
log := logrus.New()
|
log := logrus.New()
|
||||||
log.Out = ioutil.Discard
|
log.Out = ioutil.Discard
|
||||||
log.SetLevel(logrus.ErrorLevel)
|
log.SetLevel(logrus.ErrorLevel)
|
||||||
@ -58,7 +58,7 @@ func getLogLevel() logrus.Level {
|
|||||||
return level
|
return level
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDevelopmentLogger(configurer config.AppConfigurer) *logrus.Logger {
|
func newDevelopmentLogger() *logrus.Logger {
|
||||||
logger := logrus.New()
|
logger := logrus.New()
|
||||||
logger.SetLevel(getLogLevel())
|
logger.SetLevel(getLogLevel())
|
||||||
logPath, err := config.LogPath()
|
logPath, err := config.LogPath()
|
||||||
@ -76,9 +76,9 @@ func newDevelopmentLogger(configurer config.AppConfigurer) *logrus.Logger {
|
|||||||
func newLogger(config config.AppConfigurer) *logrus.Entry {
|
func newLogger(config config.AppConfigurer) *logrus.Entry {
|
||||||
var log *logrus.Logger
|
var log *logrus.Logger
|
||||||
if config.GetDebug() || os.Getenv("DEBUG") == "TRUE" {
|
if config.GetDebug() || os.Getenv("DEBUG") == "TRUE" {
|
||||||
log = newDevelopmentLogger(config)
|
log = newDevelopmentLogger()
|
||||||
} else {
|
} else {
|
||||||
log = newProductionLogger(config)
|
log = newProductionLogger()
|
||||||
}
|
}
|
||||||
|
|
||||||
// highly recommended: tail -f development.log | humanlog
|
// highly recommended: tail -f development.log | humanlog
|
||||||
|
@ -36,6 +36,7 @@ func TestIsGitVersionValid(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.versionStr, func(t *testing.T) {
|
t.Run(s.versionStr, func(t *testing.T) {
|
||||||
result := isGitVersionValid(s.versionStr)
|
result := isGitVersionValid(s.versionStr)
|
||||||
assert.Equal(t, result, s.expectedResult)
|
assert.Equal(t, result, s.expectedResult)
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aybabtme/humanlog"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/aybabtme/humanlog"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TailLogsForPlatform(logFilePath string, opts *humanlog.HandlerOptions) {
|
func TailLogsForPlatform(logFilePath string, opts *humanlog.HandlerOptions) {
|
||||||
|
@ -46,6 +46,7 @@ func TestBranchGetCommitDifferences(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := NewBranchCommandsWithRunner(s.runner)
|
||||||
pushables, pullables := instance.GetCommitDifferences("HEAD", "@{u}")
|
pushables, pullables := instance.GetCommitDifferences("HEAD", "@{u}")
|
||||||
@ -93,6 +94,7 @@ func TestBranchDeleteBranch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := NewBranchCommandsWithRunner(s.runner)
|
||||||
|
|
||||||
@ -139,6 +141,7 @@ func TestBranchCheckout(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := NewBranchCommandsWithRunner(s.runner)
|
||||||
s.test(instance.Checkout("test", CheckoutOptions{Force: s.force}))
|
s.test(instance.Checkout("test", CheckoutOptions{Force: s.force}))
|
||||||
@ -218,6 +221,7 @@ func TestBranchCurrentBranchName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := NewBranchCommandsWithRunner(s.runner)
|
instance := NewBranchCommandsWithRunner(s.runner)
|
||||||
s.test(instance.CurrentBranchName())
|
s.test(instance.CurrentBranchName())
|
||||||
|
@ -75,6 +75,7 @@ func TestCommitCommitObj(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.Commit.SignOff = s.configSignoff
|
userConfig.Git.Commit.SignOff = s.configSignoff
|
||||||
@ -109,6 +110,7 @@ func TestCommitCreateFixupCommit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildCommitCommands(commonDeps{runner: s.runner})
|
instance := buildCommitCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.CreateFixupCommit(s.sha))
|
s.test(instance.CreateFixupCommit(s.sha))
|
||||||
@ -147,6 +149,7 @@ func TestCommitShowCmdObj(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.DiffContextSize = s.contextSize
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
|
@ -27,7 +27,7 @@ func NewConfigCommands(
|
|||||||
return &ConfigCommands{
|
return &ConfigCommands{
|
||||||
Common: common,
|
Common: common,
|
||||||
gitConfig: gitConfig,
|
gitConfig: gitConfig,
|
||||||
repo: repo,
|
// repo: repo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ func TestRebaseRebaseBranch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildRebaseCommands(commonDeps{runner: s.runner})
|
instance := buildRebaseCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.RebaseBranch(s.arg))
|
s.test(instance.RebaseBranch(s.arg))
|
||||||
@ -62,6 +63,7 @@ func TestRebaseSkipEditorCommand(t *testing.T) {
|
|||||||
`^GIT_EDITOR=.*$`,
|
`^GIT_EDITOR=.*$`,
|
||||||
"^LAZYGIT_CLIENT_COMMAND=EXIT_IMMEDIATELY$",
|
"^LAZYGIT_CLIENT_COMMAND=EXIT_IMMEDIATELY$",
|
||||||
} {
|
} {
|
||||||
|
regexStr := regexStr
|
||||||
foundMatch := utils.IncludesStringFunc(envVars, func(envVar string) bool {
|
foundMatch := utils.IncludesStringFunc(envVars, func(envVar string) bool {
|
||||||
return regexp.MustCompile(regexStr).MatchString(envVar)
|
return regexp.MustCompile(regexStr).MatchString(envVar)
|
||||||
})
|
})
|
||||||
@ -135,6 +137,7 @@ func TestRebaseDiscardOldFileChanges(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildRebaseCommands(commonDeps{
|
instance := buildRebaseCommands(commonDeps{
|
||||||
runner: s.runner,
|
runner: s.runner,
|
||||||
|
@ -68,6 +68,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.DiffContextSize = s.contextSize
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
|
@ -85,6 +85,7 @@ func TestSyncPush(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildSyncCommands(commonDeps{})
|
instance := buildSyncCommands(commonDeps{})
|
||||||
s.test(instance.PushCmdObj(s.opts))
|
s.test(instance.PushCmdObj(s.opts))
|
||||||
|
@ -53,6 +53,7 @@ func TestWorkingTreeUnstageFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.UnStageFile([]string{"test.txt"}, s.reset))
|
s.test(instance.UnStageFile([]string{"test.txt"}, s.reset))
|
||||||
@ -181,6 +182,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, removeFile: s.removeFile})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, removeFile: s.removeFile})
|
||||||
err := instance.DiscardAllFileChanges(s.file)
|
err := instance.DiscardAllFileChanges(s.file)
|
||||||
@ -296,6 +298,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.DiffContextSize = s.contextSize
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
@ -345,6 +348,7 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
userConfig := config.GetDefaultConfig()
|
userConfig := config.GetDefaultConfig()
|
||||||
userConfig.Git.DiffContextSize = s.contextSize
|
userConfig.Git.DiffContextSize = s.contextSize
|
||||||
@ -392,6 +396,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
|
|
||||||
@ -445,6 +450,7 @@ func TestWorkingTreeApplyPatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.ApplyPatch("test", "cached"))
|
s.test(instance.ApplyPatch("test", "cached"))
|
||||||
@ -474,6 +480,7 @@ func TestWorkingTreeDiscardUnstagedFileChanges(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.DiscardUnstagedFileChanges(s.file))
|
s.test(instance.DiscardUnstagedFileChanges(s.file))
|
||||||
@ -501,6 +508,7 @@ func TestWorkingTreeDiscardAnyUnstagedFileChanges(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.DiscardAnyUnstagedFileChanges())
|
s.test(instance.DiscardAnyUnstagedFileChanges())
|
||||||
@ -528,6 +536,7 @@ func TestWorkingTreeRemoveUntrackedFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.RemoveUntrackedFiles())
|
s.test(instance.RemoveUntrackedFiles())
|
||||||
@ -557,6 +566,7 @@ func TestWorkingTreeResetHard(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.ResetHard(s.ref))
|
s.test(instance.ResetHard(s.ref))
|
||||||
|
@ -104,6 +104,7 @@ func TestNavigateToRepoRootDirectory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
s.test(navigateToRepoRootDirectory(s.stat, s.chdir))
|
s.test(navigateToRepoRootDirectory(s.stat, s.chdir))
|
||||||
})
|
})
|
||||||
@ -159,6 +160,7 @@ func TestSetupRepository(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
s.test(setupRepository(s.openGitRepository, s.errorStr))
|
s.test(setupRepository(s.openGitRepository, s.errorStr))
|
||||||
})
|
})
|
||||||
@ -206,6 +208,7 @@ func TestNewGitCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
s.setup()
|
s.setup()
|
||||||
s.test(NewGitCommand(utils.NewDummyCommon(), oscommands.NewDummyOSCommand(), git_config.NewFakeGitConfig(nil)))
|
s.test(NewGitCommand(utils.NewDummyCommon(), oscommands.NewDummyOSCommand(), git_config.NewFakeGitConfig(nil)))
|
||||||
@ -282,6 +285,7 @@ func TestFindDotGitDir(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
s.test(findDotGitDir(s.stat, s.readFile))
|
s.test(findDotGitDir(s.stat, s.readFile))
|
||||||
})
|
})
|
||||||
|
@ -56,6 +56,7 @@ func TestGetRepoInfoFromURL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
result, err := s.serviceDefinition.getRepoInfoFromURL(s.repoURL)
|
result, err := s.serviceDefinition.getRepoInfoFromURL(s.repoURL)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -222,6 +223,7 @@ func TestGetPullRequestURL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
tr := i18n.EnglishTranslationSet()
|
tr := i18n.EnglishTranslationSet()
|
||||||
log := &test.FakeFieldLogger{}
|
log := &test.FakeFieldLogger{}
|
||||||
|
@ -274,10 +274,7 @@ func (self *CommitLoader) getNormalRebasingCommits() ([]*models.Commit, error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
content := string(bytesContent)
|
content := string(bytesContent)
|
||||||
commit, err := self.commitFromPatch(content)
|
commit := self.commitFromPatch(content)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
commits = append([]*models.Commit{commit}, commits...)
|
commits = append([]*models.Commit{commit}, commits...)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -334,7 +331,7 @@ func (self *CommitLoader) getInteractiveRebasingCommits() ([]*models.Commit, err
|
|||||||
// From: Lazygit Tester <test@example.com>
|
// From: Lazygit Tester <test@example.com>
|
||||||
// Date: Wed, 5 Dec 2018 21:03:23 +1100
|
// Date: Wed, 5 Dec 2018 21:03:23 +1100
|
||||||
// Subject: second commit on master
|
// 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")
|
lines := strings.Split(content, "\n")
|
||||||
sha := strings.Split(lines[0], " ")[1]
|
sha := strings.Split(lines[0], " ")[1]
|
||||||
name := strings.TrimPrefix(lines[3], "Subject: ")
|
name := strings.TrimPrefix(lines[3], "Subject: ")
|
||||||
@ -342,7 +339,7 @@ func (self *CommitLoader) commitFromPatch(content string) (*models.Commit, error
|
|||||||
Sha: sha,
|
Sha: sha,
|
||||||
Name: name,
|
Name: name,
|
||||||
Status: "rebasing",
|
Status: "rebasing",
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitLoader) setCommitMergedStatuses(refName string, commits []*models.Commit) ([]*models.Commit, error) {
|
func (self *CommitLoader) setCommitMergedStatuses(refName string, commits []*models.Commit) ([]*models.Commit, error) {
|
||||||
|
@ -186,6 +186,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, scenario := range scenarios {
|
for _, scenario := range scenarios {
|
||||||
|
scenario := scenario
|
||||||
t.Run(scenario.testName, func(t *testing.T) {
|
t.Run(scenario.testName, func(t *testing.T) {
|
||||||
builder := &CommitLoader{
|
builder := &CommitLoader{
|
||||||
Common: utils.NewDummyCommon(),
|
Common: utils.NewDummyCommon(),
|
||||||
|
@ -186,6 +186,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
|
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
|
||||||
gitConfig := git_config.NewFakeGitConfig(map[string]string{"status.showUntrackedFiles": "yes"})
|
gitConfig := git_config.NewFakeGitConfig(map[string]string{"status.showUntrackedFiles": "yes"})
|
||||||
|
@ -48,6 +48,7 @@ func TestGetStashEntries(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
|
cmd := oscommands.NewDummyCmdObjBuilder(s.runner)
|
||||||
|
|
||||||
|
@ -26,11 +26,13 @@ func (self *cmdObjRunner) runWithCredentialHandling(cmdObj ICmdObj) error {
|
|||||||
case PROMPT:
|
case PROMPT:
|
||||||
return self.RunAndDetectCredentialRequest(cmdObj, self.guiIO.promptForCredentialFn)
|
return self.RunAndDetectCredentialRequest(cmdObj, self.guiIO.promptForCredentialFn)
|
||||||
case FAIL:
|
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("unexpected credential strategy")
|
||||||
return errors.New("runWithCredentialHandling called but cmdObj does not have a a credential strategy")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *cmdObjRunner) Run(cmdObj ICmdObj) error {
|
func (self *cmdObjRunner) Run(cmdObj ICmdObj) error {
|
||||||
|
@ -13,27 +13,27 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CredentialName string
|
type CredentialType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Password CredentialName = "password"
|
Password CredentialType = iota
|
||||||
Username = "username"
|
Username
|
||||||
Passphrase = "passphrase"
|
Passphrase
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunAndDetectCredentialRequest detect a username / password / passphrase question in a command
|
// 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
|
// 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
|
// 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 := ""
|
ttyText := ""
|
||||||
err := self.RunCommandWithOutputLive(cmdObj, func(word string) string {
|
err := self.RunCommandWithOutputLive(cmdObj, func(word string) string {
|
||||||
ttyText = ttyText + " " + word
|
ttyText = ttyText + " " + word
|
||||||
|
|
||||||
prompts := map[string]CredentialName{
|
prompts := map[string]CredentialType{
|
||||||
`.+'s password:`: "password",
|
`.+'s password:`: Password,
|
||||||
`Password\s*for\s*'.+':`: "password",
|
`Password\s*for\s*'.+':`: Password,
|
||||||
`Username\s*for\s*'.+':`: "username",
|
`Username\s*for\s*'.+':`: Username,
|
||||||
`Enter\s*passphrase\s*for\s*key\s*'.+':`: "passphrase",
|
`Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
|
||||||
}
|
}
|
||||||
|
|
||||||
for pattern, askFor := range prompts {
|
for pattern, askFor := range prompts {
|
||||||
|
@ -27,10 +27,10 @@ type guiIO struct {
|
|||||||
// this allows us to request info from the user like username/password, in the event
|
// this allows us to request info from the user like username/password, in the event
|
||||||
// that a command requests it.
|
// that a command requests it.
|
||||||
// the 'credential' arg is something like 'username' or 'password'
|
// 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{
|
return &guiIO{
|
||||||
log: log,
|
log: log,
|
||||||
logCommandFn: logCommandFn,
|
logCommandFn: logCommandFn,
|
||||||
@ -44,6 +44,6 @@ func NewNullGuiIO(log *logrus.Entry) *guiIO {
|
|||||||
log: log,
|
log: log,
|
||||||
logCommandFn: func(string, bool) {},
|
logCommandFn: func(string, bool) {},
|
||||||
newCmdWriterFn: func() io.Writer { return ioutil.Discard },
|
newCmdWriterFn: func() io.Writer { return ioutil.Discard },
|
||||||
promptForCredentialFn: func(CredentialName) string { return "" },
|
promptForCredentialFn: func(CredentialType) string { return "" },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,7 @@ func TestOSCommandCreateTempFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
s.test(NewDummyOSCommand().CreateTempFile(s.filename, s.content))
|
s.test(NewDummyOSCommand().CreateTempFile(s.filename, s.content))
|
||||||
})
|
})
|
||||||
|
@ -22,7 +22,7 @@ func GetHeaderFromDiff(diff string) string {
|
|||||||
func GetHunksFromDiff(diff string) []*PatchHunk {
|
func GetHunksFromDiff(diff string) []*PatchHunk {
|
||||||
hunks := []*PatchHunk{}
|
hunks := []*PatchHunk{}
|
||||||
firstLineIdx := -1
|
firstLineIdx := -1
|
||||||
var hunkLines []string
|
var hunkLines []string //nolint:prealloc
|
||||||
pastDiffHeader := false
|
pastDiffHeader := false
|
||||||
|
|
||||||
for lineIdx, line := range strings.SplitAfter(diff, "\n") {
|
for lineIdx, line := range strings.SplitAfter(diff, "\n") {
|
||||||
|
@ -511,6 +511,7 @@ func TestModifyPatchForRange(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
result := ModifiedPatchForRange(nil, s.filename, s.diffText, s.firstLineIndex, s.lastLineIndex, s.reverse, false)
|
result := ModifiedPatchForRange(nil, s.filename, s.diffText, s.firstLineIndex, s.lastLineIndex, s.reverse, false)
|
||||||
if !assert.Equal(t, s.expected, result) {
|
if !assert.Equal(t, s.expected, result) {
|
||||||
@ -538,6 +539,7 @@ func TestLineNumberOfLine(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
result := s.hunk.LineNumberOfLine(s.idx)
|
result := s.hunk.LineNumberOfLine(s.idx)
|
||||||
if !assert.Equal(t, s.expected, result) {
|
if !assert.Equal(t, s.expected, result) {
|
||||||
|
@ -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)
|
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 {
|
switch l.Kind {
|
||||||
case PATCH_HEADER:
|
case PATCH_HEADER:
|
||||||
textStyle = textStyle.SetBold()
|
textStyle = textStyle.SetBold()
|
||||||
@ -108,6 +108,8 @@ func (l *PatchLine) render(selected bool, included bool) string {
|
|||||||
textStyle = style.FgRed
|
textStyle = style.FgRed
|
||||||
case COMMIT_SHA:
|
case COMMIT_SHA:
|
||||||
textStyle = style.FgYellow
|
textStyle = style.FgYellow
|
||||||
|
default:
|
||||||
|
textStyle = theme.DefaultTextColor
|
||||||
}
|
}
|
||||||
|
|
||||||
return coloredString(textStyle, content, selected, included)
|
return coloredString(textStyle, content, selected, included)
|
||||||
|
@ -79,7 +79,7 @@ func (gui *Gui) refreshReflogCommitsConsideringStartup() {
|
|||||||
// whenever we change commits, we should update branches because the upstream/downstream
|
// 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
|
// counts can change. Whenever we change branches we should probably also change commits
|
||||||
// e.g. in the case of switching branches.
|
// e.g. in the case of switching branches.
|
||||||
func (gui *Gui) refreshCommits() error {
|
func (gui *Gui) refreshCommits() {
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
|
|
||||||
@ -110,8 +110,6 @@ func (gui *Gui) refreshCommits() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) refreshCommitsWithLimit() error {
|
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})
|
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
|
gui.State.Panels.Tags.SelectedLineIdx = 0 // Set to the top
|
||||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}})
|
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 {
|
if err := gui.Git.Tag.CreateAnnotated(tagName, commitSha, msg); err != nil {
|
||||||
return gui.surfaceError(err)
|
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 {
|
if err := gui.Git.Tag.CreateLightweight(tagName, commitSha); err != nil {
|
||||||
return gui.surfaceError(err)
|
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)
|
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
|
// we usually lazyload these commits but now that we're searching we need to load them now
|
||||||
if gui.State.Panels.Commits.LimitCommits {
|
if gui.State.Panels.Commits.LimitCommits {
|
||||||
gui.State.Panels.Commits.LimitCommits = false
|
gui.State.Panels.Commits.LimitCommits = false
|
||||||
|
@ -11,18 +11,18 @@ import (
|
|||||||
type credentials chan string
|
type credentials chan string
|
||||||
|
|
||||||
// promptUserForCredential wait for a username, password or passphrase input from the credentials popup
|
// 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.credentials = make(chan string)
|
||||||
gui.g.Update(func(g *gocui.Gui) error {
|
gui.g.Update(func(g *gocui.Gui) error {
|
||||||
credentialsView := gui.Views.Credentials
|
credentialsView := gui.Views.Credentials
|
||||||
switch passOrUname {
|
switch passOrUname {
|
||||||
case "username":
|
case oscommands.Username:
|
||||||
credentialsView.Title = gui.Tr.CredentialsUsername
|
credentialsView.Title = gui.Tr.CredentialsUsername
|
||||||
credentialsView.Mask = 0
|
credentialsView.Mask = 0
|
||||||
case "password":
|
case oscommands.Password:
|
||||||
credentialsView.Title = gui.Tr.CredentialsPassword
|
credentialsView.Title = gui.Tr.CredentialsPassword
|
||||||
credentialsView.Mask = '*'
|
credentialsView.Mask = '*'
|
||||||
case "passphrase":
|
case oscommands.Passphrase:
|
||||||
credentialsView.Title = gui.Tr.CredentialsPassphrase
|
credentialsView.Title = gui.Tr.CredentialsPassphrase
|
||||||
credentialsView.Mask = '*'
|
credentialsView.Mask = '*'
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func (gui *Gui) GenerateMenuCandidates(commandOutput, filter, valueFormat, label
|
|||||||
}
|
}
|
||||||
|
|
||||||
candidates := []commandMenuEntry{}
|
candidates := []commandMenuEntry{}
|
||||||
for _, str := range strings.Split(string(commandOutput), "\n") {
|
for _, str := range strings.Split(commandOutput, "\n") {
|
||||||
if str == "" {
|
if str == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -216,6 +216,7 @@ func (gui *Gui) menuPromptFromCommand(prompt config.CustomCommandPrompt, promptR
|
|||||||
|
|
||||||
menuItems := make([]*menuItem, len(candidates))
|
menuItems := make([]*menuItem, len(candidates))
|
||||||
for i := range candidates {
|
for i := range candidates {
|
||||||
|
i := i
|
||||||
menuItems[i] = &menuItem{
|
menuItems[i] = &menuItem{
|
||||||
displayStrings: []string{candidates[i].label},
|
displayStrings: []string{candidates[i].label},
|
||||||
onPress: func() error {
|
onPress: func() error {
|
||||||
|
@ -56,6 +56,7 @@ func TestGuiGenerateMenuCandidates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
s.test(NewDummyGui().GenerateMenuCandidates(s.cmdOut, s.filter, s.valueFormat, s.labelFormat))
|
s.test(NewDummyGui().GenerateMenuCandidates(s.cmdOut, s.filter, s.valueFormat, s.labelFormat))
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@ func TestGetSuggestedRemote(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mkRemoteList(names ...string) []*models.Remote {
|
func mkRemoteList(names ...string) []*models.Remote {
|
||||||
var result []*models.Remote
|
result := make([]*models.Remote, 0, len(names))
|
||||||
|
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
result = append(result, &models.Remote{Name: name})
|
result = append(result, &models.Remote{Name: name})
|
||||||
|
@ -648,7 +648,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool,
|
|||||||
return cmdErr == nil, gui.surfaceError(cmdErr)
|
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)
|
gui.logCommand(cmdObj.ToString(), true)
|
||||||
|
|
||||||
subprocess := cmdObj.GetCmd()
|
subprocess := cmdObj.GetCmd()
|
||||||
|
@ -17,7 +17,7 @@ func (gui *Gui) getFromAndReverseArgsForDiff(to string) (string, bool) {
|
|||||||
return from, reverse
|
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() {
|
if !gui.Git.Patch.PatchManager.Active() {
|
||||||
return gui.handleEscapePatchBuildingPanel()
|
return gui.handleEscapePatchBuildingPanel()
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func (gui *Gui) handleRefreshPatchBuildingPanel(selectedLineIdx int) error {
|
|||||||
gui.Mutexes.LineByLinePanelMutex.Lock()
|
gui.Mutexes.LineByLinePanelMutex.Lock()
|
||||||
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
|
defer gui.Mutexes.LineByLinePanelMutex.Unlock()
|
||||||
|
|
||||||
return gui.refreshPatchBuildingPanel(selectedLineIdx, gui.State.Panels.LineByLine)
|
return gui.refreshPatchBuildingPanel(selectedLineIdx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleToggleSelectionForPatch() error {
|
func (gui *Gui) handleToggleSelectionForPatch() error {
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, status patch.PatchStatus) string {
|
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, status patch.PatchStatus) string {
|
||||||
colour := theme.DefaultTextColor
|
var colour style.TextStyle
|
||||||
if diffName == name {
|
if diffName == name {
|
||||||
colour = theme.DiffTerminalColor
|
colour = theme.DiffTerminalColor
|
||||||
} else {
|
} else {
|
||||||
@ -18,6 +18,8 @@ func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFi
|
|||||||
colour = style.FgGreen
|
colour = style.FgGreen
|
||||||
case patch.PART:
|
case patch.PART:
|
||||||
colour = style.FgYellow
|
colour = style.FgYellow
|
||||||
|
case patch.UNSELECTED:
|
||||||
|
colour = theme.DefaultTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,7 @@ func (cell *Cell) setLeft(style style.TextStyle) *Cell {
|
|||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unparam
|
||||||
func (cell *Cell) setRight(style style.TextStyle, override bool) *Cell {
|
func (cell *Cell) setRight(style style.TextStyle, override bool) *Cell {
|
||||||
cell.right = true
|
cell.right = true
|
||||||
if cell.rightStyle == nil || override {
|
if cell.rightStyle == nil || override {
|
||||||
|
@ -59,6 +59,8 @@ func (gui *Gui) genericMergeCommand(command string) error {
|
|||||||
commandType = "merge"
|
commandType = "merge"
|
||||||
case enums.REBASE_MODE_REBASING:
|
case enums.REBASE_MODE_REBASING:
|
||||||
commandType = "rebase"
|
commandType = "rebase"
|
||||||
|
default:
|
||||||
|
// shouldn't be possible to land here
|
||||||
}
|
}
|
||||||
|
|
||||||
// we should end up with a command like 'git merge --continue'
|
// we should end up with a command like 'git merge --continue'
|
||||||
|
@ -110,6 +110,8 @@ func (gui *Gui) reflogUndo() error {
|
|||||||
EnvVars: undoEnvVars,
|
EnvVars: undoEnvVars,
|
||||||
WaitingStatus: undoingStatus,
|
WaitingStatus: undoingStatus,
|
||||||
})
|
})
|
||||||
|
case CURRENT_REBASE:
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.Log.Error("didn't match on the user action when trying to undo")
|
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,
|
EnvVars: redoEnvVars,
|
||||||
WaitingStatus: redoingStatus,
|
WaitingStatus: redoingStatus,
|
||||||
})
|
})
|
||||||
|
case CURRENT_REBASE:
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.Log.Error("didn't match on the user action when trying to redo")
|
gui.Log.Error("didn't match on the user action when trying to redo")
|
||||||
|
@ -114,9 +114,9 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
func() {
|
func() {
|
||||||
if options.mode == ASYNC {
|
if options.mode == ASYNC {
|
||||||
go utils.Safe(func() { _ = gui.refreshCommits() })
|
go utils.Safe(func() { gui.refreshCommits() })
|
||||||
} else {
|
} else {
|
||||||
_ = gui.refreshCommits()
|
gui.refreshCommits()
|
||||||
}
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
@ -121,10 +121,8 @@ func (u *Updater) checkForNewUpdate() (string, error) {
|
|||||||
return "", errors.New(errMessage)
|
return "", errors.New(errMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
rawUrl, err := u.getBinaryUrl(newVersion)
|
rawUrl := u.getBinaryUrl(newVersion)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
u.Log.Info("Checking for resource at url " + rawUrl)
|
u.Log.Info("Checking for resource at url " + rawUrl)
|
||||||
if !u.verifyResourceFound(rawUrl) {
|
if !u.verifyResourceFound(rawUrl) {
|
||||||
errMessage := utils.ResolvePlaceholderString(
|
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
|
// 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(
|
url := fmt.Sprintf(
|
||||||
"%s/releases/download/%s/lazygit_%s_%s_%s.%s",
|
"%s/releases/download/%s/lazygit_%s_%s_%s.%s",
|
||||||
constants.Links.RepoUrl,
|
constants.Links.RepoUrl,
|
||||||
@ -235,7 +233,7 @@ func (u *Updater) getBinaryUrl(newVersion string) (string, error) {
|
|||||||
u.zipExtension(),
|
u.zipExtension(),
|
||||||
)
|
)
|
||||||
u.Log.Info("Url for latest release is " + url)
|
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
|
// 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 {
|
func (u *Updater) update(newVersion string) error {
|
||||||
rawUrl, err := u.getBinaryUrl(newVersion)
|
rawUrl := u.getBinaryUrl(newVersion)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
u.Log.Info("Updating with url " + rawUrl)
|
u.Log.Info("Updating with url " + rawUrl)
|
||||||
return u.downloadAndInstall(rawUrl)
|
return u.downloadAndInstall(rawUrl)
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ func TestNextIndex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
assert.EqualValues(t, s.expected, NextIndex(s.list, s.element))
|
assert.EqualValues(t, s.expected, NextIndex(s.list, s.element))
|
||||||
})
|
})
|
||||||
@ -128,6 +129,7 @@ func TestPrevIndex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
assert.EqualValues(t, s.expected, PrevIndex(s.list, s.element))
|
assert.EqualValues(t, s.expected, PrevIndex(s.list, s.element))
|
||||||
})
|
})
|
||||||
@ -160,6 +162,7 @@ func TestEscapeSpecialChars(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
assert.EqualValues(t, s.expected, EscapeSpecialChars(s.input))
|
assert.EqualValues(t, s.expected, EscapeSpecialChars(s.input))
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user