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

Add demo for diffing two commits

This commit is contained in:
Jesse Duffield 2023-08-12 17:17:32 +10:00
parent b1bc437d1b
commit 83d642b74f
3 changed files with 51 additions and 0 deletions

View File

@ -150,6 +150,12 @@ When viewing the commit graph in an enlarged window (use `+` and `_` to cycle wi
![commit_graph](../assets/demo/commit_graph-compressed.gif)
### Compare two commits
If you press `shift+w` on a commit (or branch/ref) a menu will open that allows you to mark that commit so that any other commit you select will be diffed against it. Once you've selected the second commit, you'll see the diff in the main view and if you press `<enter>` you'll see the files of the diff. You can press `shift+w` to view the diff menu again to see options like reversing the diff direction or exiting diff mode. You can also exit diff mode by pressing `<escape>`.
![diff_commits](../assets/demo/diff_commits-compressed.gif)
## Tutorials
[<img src="https://i.imgur.com/sVEktDn.png">](https://youtu.be/CPLdltN7wgE)

View File

@ -0,0 +1,44 @@
package demo
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Diff two commits",
ExtraCmdArgs: []string{},
Skip: false,
IsDemo: true,
SetupConfig: func(config *config.AppConfig) {
setDefaultDemoConfig(config)
config.UserConfig.Gui.ShowFileTree = false
config.UserConfig.Gui.ShowCommandLog = false
},
SetupRepo: func(shell *Shell) {
shell.CreateNCommitsWithRandomMessages(50)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.SetCaptionPrefix("Compare two commits")
t.Wait(1000)
t.Views().Commits().
Focus().
NavigateToLine(Contains("Replace deprecated lifecycle methods in React components")).
Wait(1000).
Press(keys.Universal.DiffingMenu).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Diffing")).
TopLines(
MatchesRegexp(`Diff .*`),
).
Wait(500).
Confirm()
}).
NavigateToLine(Contains("Move constants to a separate config file")).
Wait(1000).
PressEnter()
},
})

View File

@ -96,6 +96,7 @@ var tests = []*components.IntegrationTest{
demo.CommitGraph,
demo.CustomCommand,
demo.CustomPatch,
demo.DiffCommits,
demo.Filter,
demo.InteractiveRebase,
demo.NukeWorkingTree,