mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 05:57:38 -04:00
Update demos and readme for new staging-in-main-view functionality
We don't bother rendering the updated or new demos yet, because we are about to change them to a different format.
This commit is contained in:
@@ -10,66 +10,99 @@ var usersFileContent = `package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// TODO: verify that this actually works
|
||||
fmt.Println(shims.Greeting())
|
||||
serve()
|
||||
}
|
||||
|
||||
func serve() {
|
||||
fmt.Println("listening on :8080")
|
||||
}
|
||||
`
|
||||
|
||||
var usersFileContentWithLogging = `package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello world")
|
||||
serve()
|
||||
}
|
||||
|
||||
func logRequest(path string) {
|
||||
fmt.Println("request:", path)
|
||||
}
|
||||
|
||||
func serve() {
|
||||
fmt.Println("listening on :8080")
|
||||
}
|
||||
`
|
||||
|
||||
var CustomPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Remove a line from an old commit",
|
||||
Description: "Split a change out of an old commit into a new one",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
IsDemo: true,
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
setDefaultDemoConfig(cfg)
|
||||
cfg.GetUserConfig().Gui.UseHunkModeInDiffView = false
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateNCommitsWithRandomMessages(30)
|
||||
shell.NewBranch("feature/user-authentication")
|
||||
shell.EmptyCommit("Add user authentication feature")
|
||||
shell.CreateFileAndAdd("src/users.go", "package main\n")
|
||||
shell.CreateFileAndAdd("src/users.go", usersFileContent)
|
||||
shell.Commit("Fix local session storage")
|
||||
shell.CreateFile("src/authentication.go", "package main")
|
||||
shell.CreateFile("src/session.go", "package main")
|
||||
shell.UpdateFileAndAdd("src/users.go", usersFileContent)
|
||||
shell.EmptyCommit("Stop using shims")
|
||||
shell.UpdateFileAndAdd("src/users.go", usersFileContentWithLogging)
|
||||
shell.Commit("Stop using shims")
|
||||
shell.UpdateFileAndAdd("src/authentication.go", "package authentication")
|
||||
shell.UpdateFileAndAdd("src/session.go", "package session")
|
||||
shell.Commit("Enhance user authentication feature")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.SetCaptionPrefix("Remove a line from an old commit")
|
||||
t.SetCaptionPrefix("Split a change out of an old commit")
|
||||
t.Wait(1000)
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
NavigateToLine(Contains("Stop using shims")).
|
||||
Wait(1000).
|
||||
PressEnter().
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Wait(1000).
|
||||
Press(keys.Universal.NextItem).
|
||||
SelectedLines(
|
||||
Contains("+func logRequest(path string) {"),
|
||||
Contains(`fmt.Println("request:", path)`),
|
||||
Contains("+}"),
|
||||
Equals("+"),
|
||||
).
|
||||
Wait(500).
|
||||
SetCaptionPrefix("Add the hunk to a custom patch").
|
||||
PressPrimaryAction().
|
||||
Wait(1000).
|
||||
SetCaptionPrefix("Move the patch into a new commit").
|
||||
Press(keys.Universal.CreatePatchOptionsMenu).
|
||||
Tap(func() {
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
NavigateToLine(Contains("users.go")).
|
||||
Wait(1000).
|
||||
PressEnter().
|
||||
Tap(func() {
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
NavigateToLine(Contains("TODO")).
|
||||
Wait(500).
|
||||
PressPrimaryAction().
|
||||
PressEscape()
|
||||
}).
|
||||
Press(keys.Universal.CreatePatchOptionsMenu).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Patch options")).
|
||||
Select(Contains("Remove patch from original commit")).
|
||||
Wait(500).
|
||||
Confirm()
|
||||
}).
|
||||
PressEscape()
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Patch options")).
|
||||
Select(Contains("Move patch into new commit after the original commit")).
|
||||
Wait(500).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
Type("Add request logging").
|
||||
Confirm()
|
||||
})
|
||||
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
TopLines(
|
||||
Contains("Enhance user authentication feature"),
|
||||
Contains("Add request logging"),
|
||||
Contains("Stop using shims"),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package demo
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var greetingFileContent = `package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func greet(name string) {
|
||||
fmt.Println("hello", name)
|
||||
}
|
||||
|
||||
func farewell(name string) {
|
||||
fmt.Println("bye", name)
|
||||
}
|
||||
`
|
||||
|
||||
var greetingFileContentWithDebugLine = `package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func greet(name string) {
|
||||
fmt.Println("hello there", name)
|
||||
}
|
||||
|
||||
func farewell(name string) {
|
||||
fmt.Println("DEBUG: saying bye to", name)
|
||||
fmt.Println("bye", name)
|
||||
}
|
||||
`
|
||||
|
||||
var RemoveHunkFromCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Remove a hunk from an old commit",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
IsDemo: true,
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
setDefaultDemoConfig(cfg)
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateNCommitsWithRandomMessages(30)
|
||||
shell.NewBranch("feature/user-authentication")
|
||||
shell.CreateFileAndAdd("src/greeting.go", greetingFileContent)
|
||||
shell.Commit("Greet users when they sign in")
|
||||
shell.UpdateFileAndAdd("src/greeting.go", greetingFileContentWithDebugLine)
|
||||
shell.Commit("Make the greeting friendlier")
|
||||
shell.EmptyCommit("Expire sessions after a day")
|
||||
shell.EmptyCommit("Enhance user authentication feature")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.SetCaptionPrefix("Remove a hunk from an old commit")
|
||||
t.Wait(1000)
|
||||
|
||||
t.Views().Commits().
|
||||
Focus().
|
||||
NavigateToLine(Contains("Make the greeting friendlier")).
|
||||
Wait(1000).
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
Wait(1000).
|
||||
Press(keys.Universal.NextItem).
|
||||
SelectedLines(
|
||||
Contains(`fmt.Println("DEBUG: saying bye to", name)`),
|
||||
).
|
||||
Wait(1000).
|
||||
Press(keys.Universal.Remove).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Discard lines from commit")).
|
||||
Content(AnyString()).
|
||||
Wait(1000).
|
||||
Confirm()
|
||||
}).
|
||||
Wait(1000).
|
||||
Content(Contains(`fmt.Println("hello there", name)`).DoesNotContain("DEBUG"))
|
||||
},
|
||||
})
|
||||
+26
-12
@@ -30,11 +30,11 @@ Simple terminal UI for git
|
||||
|
||||
Just do brew install lazygit and bada bing bada
|
||||
boom you have begun on the path of laziness.
|
||||
|
||||
TODO: mention the other install methods
|
||||
`
|
||||
|
||||
var StageLines = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stage individual lines",
|
||||
var StageHunksOrLines = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Stage hunks or individual lines",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
IsDemo: true,
|
||||
@@ -51,29 +51,43 @@ var StageLines = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.UpdateFile("docs/README.md", updatedFile)
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.SetCaptionPrefix("Stage individual lines")
|
||||
t.SetCaptionPrefix("Stage a hunk")
|
||||
t.Wait(1000)
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
PressEnter()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(
|
||||
Contains("-Simple terminal UI for git commands"),
|
||||
Contains("+Simple terminal UI for git"),
|
||||
Contains("+(Not too simple though)"),
|
||||
).
|
||||
Wait(1000).
|
||||
PressPrimaryAction().
|
||||
Wait(1000).
|
||||
SetCaptionPrefix("Stage individual lines").
|
||||
Press(keys.Main.ToggleSelectHunk).
|
||||
Wait(500).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
PressFast(keys.Universal.NextItem).
|
||||
PressFast(keys.Universal.NextItem).
|
||||
SelectedLines(
|
||||
Contains("+Just do brew install lazygit"),
|
||||
Contains("+boom you have begun"),
|
||||
).
|
||||
Wait(500).
|
||||
PressPrimaryAction().
|
||||
Wait(500).
|
||||
PressEscape()
|
||||
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
Wait(1000).
|
||||
SelectedLines(
|
||||
Contains("+TODO: mention the other install methods"),
|
||||
).
|
||||
SetCaptionPrefix("Commit our changes").
|
||||
Press(keys.Files.CommitChanges).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
Type("Update tagline").
|
||||
Type("Update tagline and install instructions").
|
||||
Confirm()
|
||||
})
|
||||
|
||||
@@ -219,7 +219,8 @@ var tests = []*components.IntegrationTest{
|
||||
demo.InteractiveRebase,
|
||||
demo.NukeWorkingTree,
|
||||
demo.RebaseOnto,
|
||||
demo.StageLines,
|
||||
demo.RemoveHunkFromCommit,
|
||||
demo.StageHunksOrLines,
|
||||
demo.Undo,
|
||||
demo.WorktreeCreateFromBranches,
|
||||
diff.CopyToClipboard,
|
||||
|
||||
Reference in New Issue
Block a user