mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-29 23:17:32 +02:00
format code
This commit is contained in:
parent
148bf2c070
commit
713fae3e32
@ -139,7 +139,7 @@ func (gui *Gui) GenerateMenuCandidates(commandOutput string, filter string, form
|
|||||||
for groupIdx, group := range reg.SubexpNames() {
|
for groupIdx, group := range reg.SubexpNames() {
|
||||||
// Record matched group with group ids
|
// Record matched group with group ids
|
||||||
matchName := "group_" + strconv.Itoa(groupIdx)
|
matchName := "group_" + strconv.Itoa(groupIdx)
|
||||||
tmplData[matchName] = out[0][groupIdx]
|
tmplData[matchName] = out[0][groupIdx]
|
||||||
// Record last named group non-empty matches as group matches
|
// Record last named group non-empty matches as group matches
|
||||||
if group != "" {
|
if group != "" {
|
||||||
tmplData[group] = out[0][groupIdx]
|
tmplData[group] = out[0][groupIdx]
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
"github.com/jesseduffield/lazygit/pkg/updates"
|
"github.com/jesseduffield/lazygit/pkg/updates"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDummyGui creates a new dummy GUI for testing
|
// NewDummyGui creates a new dummy GUI for testing
|
||||||
func NewDummyUpdater() *updates.Updater {
|
func NewDummyUpdater() *updates.Updater {
|
||||||
DummyUpdater, _ := updates.NewUpdater(utils.NewDummyLog(), config.NewDummyAppConfig(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog()))
|
DummyUpdater, _ := updates.NewUpdater(utils.NewDummyLog(), config.NewDummyAppConfig(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog()))
|
||||||
return DummyUpdater
|
return DummyUpdater
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDummyGui() *Gui {
|
func NewDummyGui() *Gui {
|
||||||
DummyGui, _ := NewGui(utils.NewDummyLog(), commands.NewDummyGitCommand(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog()), config.NewDummyAppConfig(), NewDummyUpdater(), "", false)
|
DummyGui, _ := NewGui(utils.NewDummyLog(), commands.NewDummyGitCommand(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog()), config.NewDummyAppConfig(), NewDummyUpdater(), "", false)
|
||||||
return DummyGui
|
return DummyGui
|
||||||
}
|
}
|
||||||
|
@ -86,39 +86,39 @@ func TestGuiGenerateMenuCandidates(t *testing.T) {
|
|||||||
testName string
|
testName string
|
||||||
cmdOut string
|
cmdOut string
|
||||||
filter string
|
filter string
|
||||||
format string
|
format string
|
||||||
test func([]string, error)
|
test func([]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
"Extract remote branch name",
|
"Extract remote branch name",
|
||||||
"upstream/pr-1",
|
"upstream/pr-1",
|
||||||
"upstream/(?P<branch>.*)",
|
"upstream/(?P<branch>.*)",
|
||||||
"{{ .branch }}",
|
"{{ .branch }}",
|
||||||
func(actual []string, err error) {
|
func(actual []string, err error) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "pr-1", actual[0])
|
assert.EqualValues(t, "pr-1", actual[0])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Multiple named groups",
|
"Multiple named groups",
|
||||||
"upstream/pr-1",
|
"upstream/pr-1",
|
||||||
"(?P<remote>[a-z]*)/(?P<branch>.*)",
|
"(?P<remote>[a-z]*)/(?P<branch>.*)",
|
||||||
"{{ .branch }}|{{ .remote }}",
|
"{{ .branch }}|{{ .remote }}",
|
||||||
func(actual []string, err error) {
|
func(actual []string, err error) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "pr-1|upstream", actual[0])
|
assert.EqualValues(t, "pr-1|upstream", actual[0])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Multiple named groups with group ids",
|
"Multiple named groups with group ids",
|
||||||
"upstream/pr-1",
|
"upstream/pr-1",
|
||||||
"(?P<remote>[a-z]*)/(?P<branch>.*)",
|
"(?P<remote>[a-z]*)/(?P<branch>.*)",
|
||||||
"{{ .group_2 }}|{{ .group_1 }}",
|
"{{ .group_2 }}|{{ .group_1 }}",
|
||||||
func(actual []string, err error) {
|
func(actual []string, err error) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "pr-1|upstream", actual[0])
|
assert.EqualValues(t, "pr-1|upstream", actual[0])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user