1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00

Merge pull request #2466 from jesseduffield/migrate-reflog-tests

This commit is contained in:
Jesse Duffield 2023-02-22 22:33:57 +11:00 committed by GitHub
commit 558ceb64c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
798 changed files with 1106 additions and 1978 deletions

View File

@ -17,3 +17,17 @@ func (self *Actions) ContinueMerge() {
func (self *Actions) ContinueRebase() {
self.ContinueMerge()
}
func (self *Actions) AcknowledgeConflicts() {
self.t.ExpectPopup().Confirmation().
Title(Equals("Auto-merge failed")).
Content(Contains("Conflicts!")).
Confirm()
}
func (self *Actions) ContinueOnConflictsResolved() {
self.t.ExpectPopup().Confirmation().
Title(Equals("continue")).
Content(Contains("all merge conflicts resolved. Continue?")).
Confirm()
}

View File

@ -32,8 +32,7 @@ func (self *PromptDriver) Type(value string) *PromptDriver {
}
func (self *PromptDriver) Clear() *PromptDriver {
// TODO: soft-code this
self.t.press("<c-u>")
self.t.press(ClearKey)
return self
}

View File

@ -0,0 +1,39 @@
package components
// TODO: soft-code this
const ClearKey = "<c-u>"
type SearchDriver struct {
t *TestDriver
}
func (self *SearchDriver) getViewDriver() *ViewDriver {
return self.t.Views().Search()
}
// asserts on the text initially present in the prompt
func (self *SearchDriver) InitialText(expected *matcher) *SearchDriver {
self.getViewDriver().Content(expected)
return self
}
func (self *SearchDriver) Type(value string) *SearchDriver {
self.t.typeContent(value)
return self
}
func (self *SearchDriver) Clear() *SearchDriver {
self.t.press(ClearKey)
return self
}
func (self *SearchDriver) Confirm() {
self.getViewDriver().PressEnter()
}
func (self *SearchDriver) Cancel() {
self.getViewDriver().PressEscape()
}

View File

@ -179,7 +179,7 @@ func (self *Shell) StashWithMessage(message string) *Shell {
}
func (self *Shell) SetConfig(key string, value string) *Shell {
self.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value))
self.RunCommand(fmt.Sprintf(`git config --local "%s" "%s"`, key, value))
return self
}

View File

@ -159,6 +159,19 @@ func (self *TestDriver) ExpectClipboard(matcher *matcher) {
})
}
func (self *TestDriver) ExpectSearch() *SearchDriver {
self.inSearch()
return &SearchDriver{t: self}
}
func (self *TestDriver) inSearch() {
self.assertWithRetries(func() (bool, string) {
currentView := self.gui.CurrentContext().GetView()
return currentView.Name() == "search", "Expected search prompt to be focused"
})
}
// for making assertions through git itself
func (self *TestDriver) Git() *Git {
return &Git{assertionHelper: self.assertionHelper, shell: self.shell}

View File

@ -127,3 +127,7 @@ func (self *Views) Suggestions() *ViewDriver {
func (self *Views) MergeConflicts() *ViewDriver {
return self.byName("mergeConflicts")
}
func (self *Views) Search() *ViewDriver {
return self.byName("search")
}

View File

@ -35,10 +35,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Content(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?")).
Confirm()
t.ExpectPopup().Confirmation().
Title(Equals("Auto-merge failed")).
Content(Contains("Conflicts!")).
Confirm()
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@ -51,10 +48,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("rebasing"))
t.ExpectPopup().Confirmation().
Title(Equals("continue")).
Content(Contains("all merge conflicts resolved. Continue?")).
Confirm()
t.Actions().ContinueOnConflictsResolved()
t.Views().Information().Content(DoesNotContain("rebasing"))

View File

@ -43,10 +43,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("rebasing"))
t.ExpectPopup().Confirmation().
Title(Equals("Auto-merge failed")).
Content(Contains("Conflicts!")).
Confirm()
t.Actions().AcknowledgeConflicts()
t.Views().Files().IsFocused().
SelectedLine(MatchesRegexp("UU.*file"))
@ -78,10 +75,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
IsFocused().
PressPrimaryAction()
t.ExpectPopup().Confirmation().
Title(Equals("continue")).
Content(Contains("all merge conflicts resolved. Continue?")).
Confirm()
t.Actions().ContinueOnConflictsResolved()
t.Views().Information().Content(DoesNotContain("rebasing"))

View File

@ -0,0 +1,36 @@
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ResetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reset the upstream of a branch",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
Lines(
Contains("master").Contains("origin master").IsSelected(),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Set/unset upstream")).
Select(Contains("unset upstream of selected branch")).
Confirm()
}).
Lines(
Contains("master").DoesNotContain("origin master").IsSelected(),
)
},
})

View File

@ -0,0 +1,40 @@
package branch
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Set the upstream of a branch",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.CloneIntoRemote("origin")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Focus().
Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
Lines(
Contains("master").DoesNotContain("origin master").IsSelected(),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Set/unset upstream")).
Select(Contains(" set upstream of selected branch")). // using leading space to disambiguate from the 'reset' option
Confirm()
t.ExpectPopup().Prompt().
Title(Equals("Enter upstream as '<remote> <branchname>'")).
SuggestionLines(Equals("origin master")).
ConfirmFirstSuggestion()
}).
Lines(
Contains("master").Contains("origin master").IsSelected(),
)
},
})

View File

@ -47,13 +47,13 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
).
Press(keys.Commits.PasteCommits)
t.ExpectPopup().Alert().Title(Equals("Cherry-Pick")).Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).Confirm()
t.ExpectPopup().Confirmation().
Title(Equals("Auto-merge failed")).
Content(Contains("Conflicts!")).
t.ExpectPopup().Alert().
Title(Equals("Cherry-Pick")).
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
Confirm()
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
SelectedLine(Contains("file")).
@ -65,10 +65,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
SelectNextItem().
PressPrimaryAction()
t.ExpectPopup().Confirmation().
Title(Equals("continue")).
Content(Contains("all merge conflicts resolved. Continue?")).
Confirm()
t.Actions().ContinueOnConflictsResolved()
t.Views().Files().IsEmpty()

View File

@ -0,0 +1,39 @@
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var ResetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reset author on a commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.SetConfig("user.email", "Bill@example.com")
shell.SetConfig("user.name", "Bill Smith")
shell.EmptyCommit("one")
shell.SetConfig("user.email", "John@example.com")
shell.SetConfig("user.name", "John Smith")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("BS").Contains("one").IsSelected(),
).
Press(keys.Commits.ResetCommitAuthor).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Amend commit attribute")).
Select(Contains("reset author")).
Confirm()
}).
Lines(
Contains("JS").Contains("one").IsSelected(),
)
},
})

View File

@ -0,0 +1,107 @@
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Search = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Search for a commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.EmptyCommit("three")
shell.EmptyCommit("four")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.StartSearch).
Tap(func() {
t.ExpectSearch().
Type("two").
Confirm()
t.Views().Search().Content(Contains("matches for 'two' (1 of 1)"))
}).
Lines(
Contains("four"),
Contains("three"),
Contains("two").IsSelected(),
Contains("one"),
).
Press(keys.Universal.StartSearch).
Tap(func() {
t.ExpectSearch().
Type("o").
Confirm()
t.Views().Search().Content(Contains("matches for 'o' (2 of 3)"))
}).
Lines(
Contains("four"),
Contains("three"),
Contains("two").IsSelected(),
Contains("one"),
).
Press("n").
Tap(func() {
t.Views().Search().Content(Contains("matches for 'o' (3 of 3)"))
}).
Lines(
Contains("four"),
Contains("three"),
Contains("two"),
Contains("one").IsSelected(),
).
Press("n").
Tap(func() {
t.Views().Search().Content(Contains("matches for 'o' (1 of 3)"))
}).
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
Press("n").
Tap(func() {
t.Views().Search().Content(Contains("matches for 'o' (2 of 3)"))
}).
Lines(
Contains("four"),
Contains("three"),
Contains("two").IsSelected(),
Contains("one"),
).
Press("N").
Tap(func() {
t.Views().Search().Content(Contains("matches for 'o' (1 of 3)"))
}).
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
).
Press("N").
Tap(func() {
t.Views().Search().Content(Contains("matches for 'o' (3 of 3)"))
}).
Lines(
Contains("four"),
Contains("three"),
Contains("two"),
Contains("one").IsSelected(),
)
},
})

View File

@ -0,0 +1,51 @@
package commit
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SetAuthor = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Set author on a commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.SetConfig("user.email", "Bill@example.com")
shell.SetConfig("user.name", "Bill Smith")
shell.EmptyCommit("one")
shell.SetConfig("user.email", "John@example.com")
shell.SetConfig("user.name", "John Smith")
shell.EmptyCommit("two")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
Lines(
Contains("JS").Contains("two").IsSelected(),
Contains("BS").Contains("one"),
).
Press(keys.Commits.ResetCommitAuthor).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Amend commit attribute")).
Select(Contains(" set author")). // adding space at start to distinguish from 'reset author'
Confirm()
t.ExpectPopup().Prompt().
Title(Contains("Set author")).
SuggestionLines(
Contains("John Smith"),
Contains("Bill Smith"),
).
ConfirmSuggestion(Contains("John Smith"))
}).
Lines(
Contains("JS").Contains("two").IsSelected(),
Contains("BS").Contains("one"),
)
},
})

View File

@ -99,10 +99,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
{status: "DU", label: "deleted-us.txt", menuTitle: "deleted-us.txt"},
})
t.ExpectPopup().Confirmation().
Title(Equals("continue")).
Content(Contains("all merge conflicts resolved. Continue?")).
Cancel()
t.Actions().ContinueOnConflictsResolved()
discardOneByOne([]statusFile{
{status: "MD", label: "change-delete.txt", menuTitle: "change-delete.txt"},

View File

@ -49,21 +49,7 @@ var SwapInRebaseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
})
func handleConflictsFromSwap(t *TestDriver) {
continueMerge := func() {
t.ExpectPopup().Confirmation().
Title(Equals("continue")).
Content(Contains("all merge conflicts resolved. Continue?")).
Confirm()
}
acceptConflicts := func() {
t.ExpectPopup().Confirmation().
Title(Equals("Auto-merge failed")).
Content(Contains("Conflicts!")).
Confirm()
}
acceptConflicts()
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@ -84,9 +70,9 @@ func handleConflictsFromSwap(t *TestDriver) {
SelectNextItem().
PressPrimaryAction() // pick "three"
continueMerge()
t.Actions().ContinueOnConflictsResolved()
acceptConflicts()
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@ -107,7 +93,7 @@ func handleConflictsFromSwap(t *TestDriver) {
SelectNextItem().
PressPrimaryAction() // pick "two"
continueMerge()
t.Actions().ContinueOnConflictsResolved()
t.Views().Commits().
Focus().

View File

@ -0,0 +1,55 @@
package reflog
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Checkout a reflog commit as a detached head",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.EmptyCommit("three")
shell.HardReset("HEAD^^")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().ReflogCommits().
Focus().
Lines(
Contains("reset: moving to HEAD^^").IsSelected(),
Contains("commit: three"),
Contains("commit: two"),
Contains("commit (initial): one"),
).
SelectNextItem().
PressPrimaryAction().
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Contains("checkout commit")).
Content(Contains("Are you sure you want to checkout this commit?")).
Confirm()
}).
TopLines(
Contains("checkout: moving from master to").IsSelected(),
Contains("reset: moving to HEAD^^"),
)
t.Views().Branches().
Lines(
Contains("(HEAD detached at").IsSelected(),
Contains("master"),
)
t.Views().Commits().
Focus().
Lines(
Contains("three").IsSelected(),
Contains("two"),
Contains("one"),
)
},
})

View File

@ -0,0 +1,50 @@
package reflog
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cherry pick a reflog commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.EmptyCommit("three")
shell.HardReset("HEAD^^")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().ReflogCommits().
Focus().
Lines(
Contains("reset: moving to HEAD^^").IsSelected(),
Contains("commit: three"),
Contains("commit: two"),
Contains("commit (initial): one"),
).
SelectNextItem().
Press(keys.Commits.CherryPickCopy)
t.Views().Information().Content(Contains("1 commit copied"))
t.Views().Commits().
Focus().
Lines(
Contains("one").IsSelected(),
).
Press(keys.Commits.PasteCommits).
Tap(func() {
t.ExpectPopup().Alert().
Title(Equals("Cherry-Pick")).
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
Confirm()
}).
Lines(
Contains("three").IsSelected(),
Contains("one"),
)
},
})

View File

@ -0,0 +1,64 @@
package reflog
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Patch = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Build a patch from a reflog commit and apply it",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.CreateFileAndAdd("file1", "content1")
shell.CreateFileAndAdd("file2", "content2")
shell.Commit("three")
shell.HardReset("HEAD^^")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().ReflogCommits().
Focus().
Lines(
Contains("reset: moving to HEAD^^").IsSelected(),
Contains("commit: three"),
Contains("commit: two"),
Contains("commit (initial): one"),
).
SelectNextItem().
PressEnter()
t.Views().SubCommits().
IsFocused().
Lines(
Contains("three").IsSelected(),
Contains("two"),
Contains("one"),
).
PressEnter()
t.Views().CommitFiles().
IsFocused().
Lines(
Contains("file1").IsSelected(),
Contains("file2"),
).
PressPrimaryAction()
t.Views().Information().Content(Contains("building patch"))
t.Views().
CommitFiles().
Press(keys.Universal.CreatePatchOptionsMenu)
t.ExpectPopup().Menu().
Title(Equals("Patch Options")).
Select(MatchesRegexp(`apply patch$`)).Confirm()
t.Views().Files().Lines(
Contains("file1"),
)
},
})

View File

@ -0,0 +1,49 @@
package reflog
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Reset = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Hard reset to a reflog commit",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.EmptyCommit("three")
shell.HardReset("HEAD^^")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().ReflogCommits().
Focus().
Lines(
Contains("reset: moving to HEAD^^").IsSelected(),
Contains("commit: three"),
Contains("commit: two"),
Contains("commit (initial): one"),
).
SelectNextItem().
Press(keys.Commits.ViewResetOptions).
Tap(func() {
t.ExpectPopup().Menu().
Title(Contains("reset to")).
Select(Contains("hard reset")).
Confirm()
}).
TopLines(
Contains("reset: moving to").IsSelected(),
Contains("reset: moving to HEAD^^"),
)
t.Views().Commits().
Focus().
Lines(
Contains("three").IsSelected(),
Contains("two"),
Contains("one"),
)
},
})

View File

@ -0,0 +1,42 @@
package staging
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Search = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Use the search feature in the staging panel",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFile("file1", "one\ntwo\nthree\nfour\nfive")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains("file1").IsSelected(),
).
PressEnter()
t.Views().Staging().
IsFocused().
Press(keys.Universal.StartSearch).
Tap(func() {
t.ExpectSearch().
Type("four").
Confirm()
t.Views().Search().Content(Contains("matches for 'four' (1 of 1)"))
}).
SelectedLine(Contains("+four")). // stage the line
PressPrimaryAction().
Content(DoesNotContain("+four")).
Tap(func() {
t.Views().StagingSecondary().
Content(Contains("+four"))
})
},
})

View File

@ -0,0 +1,53 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var PullMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pull with a merge strategy",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "content1")
shell.Commit("one")
shell.UpdateFileAndAdd("file", "content2")
shell.Commit("two")
shell.EmptyCommit("three")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.HardReset("HEAD^^")
shell.EmptyCommit("four")
shell.SetConfig("pull.rebase", "false")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("four"),
Contains("one"),
)
t.Views().Status().Content(Contains("↓2 repo → master"))
t.Views().Files().
IsFocused().
Press(keys.Universal.Pull)
t.Views().Status().Content(Contains("↑2 repo → master"))
t.Views().Commits().
Lines(
Contains("Merge branch 'master' of ../origin"),
Contains("three"),
Contains("two"),
Contains("four"),
Contains("one"),
)
},
})

View File

@ -0,0 +1,84 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var PullMergeConflict = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pull with a merge strategy, where a conflict occurs",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "content1")
shell.Commit("one")
shell.UpdateFileAndAdd("file", "content2")
shell.Commit("two")
shell.EmptyCommit("three")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.HardReset("HEAD^^")
shell.UpdateFileAndAdd("file", "content4")
shell.Commit("four")
shell.SetConfig("pull.rebase", "false")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("four"),
Contains("one"),
)
t.Views().Status().Content(Contains("↓2 repo → master"))
t.Views().Files().
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU").Contains("file"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("content4"),
Contains("======="),
Contains("content2"),
Contains(">>>>>>>"),
).
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑2 repo → master"))
t.Views().Commits().
Focus().
Lines(
Contains("Merge branch 'master' of ../origin").IsSelected(),
Contains("three"),
Contains("two"),
Contains("four"),
Contains("one"),
)
t.Views().Main().
Content(
Contains("- content4").
Contains(" -content2").
Contains("++content4"),
)
},
})

View File

@ -0,0 +1,52 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var PullRebase = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pull with a rebase strategy",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "content1")
shell.Commit("one")
shell.UpdateFileAndAdd("file", "content2")
shell.Commit("two")
shell.EmptyCommit("three")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.HardReset("HEAD^^")
shell.EmptyCommit("four")
shell.SetConfig("pull.rebase", "true")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("four"),
Contains("one"),
)
t.Views().Status().Content(Contains("↓2 repo → master"))
t.Views().Files().
IsFocused().
Press(keys.Universal.Pull)
t.Views().Status().Content(Contains("↑1 repo → master"))
t.Views().Commits().
Lines(
Contains("four"),
Contains("three"),
Contains("two"),
Contains("one"),
)
},
})

View File

@ -0,0 +1,83 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var PullRebaseConflict = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pull with a rebase strategy, where a conflict occurs",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "content1")
shell.Commit("one")
shell.UpdateFileAndAdd("file", "content2")
shell.Commit("two")
shell.EmptyCommit("three")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.HardReset("HEAD^^")
shell.UpdateFileAndAdd("file", "content4")
shell.Commit("four")
shell.SetConfig("pull.rebase", "true")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("four"),
Contains("one"),
)
t.Views().Status().Content(Contains("↓2 repo → master"))
t.Views().Files().
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU").Contains("file"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("content2"),
Contains("======="),
Contains("content4"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑1 repo → master"))
t.Views().Commits().
Focus().
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
)
t.Views().Main().
Content(
Contains("-content2").
Contains("+content4"),
)
},
})

View File

@ -0,0 +1,95 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pull with an interactive rebase strategy, where a conflict occurs",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "content1")
shell.Commit("one")
shell.UpdateFileAndAdd("file", "content2")
shell.Commit("two")
shell.EmptyCommit("three")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.HardReset("HEAD^^")
shell.UpdateFileAndAdd("file", "content4")
shell.Commit("four")
shell.EmptyCommit("five")
shell.SetConfig("pull.rebase", "interactive")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("five"),
Contains("four"),
Contains("one"),
)
t.Views().Status().Content(Contains("↓2 repo → master"))
t.Views().Files().
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Views().Commits().
Lines(
Contains("pick").Contains("five"),
Contains("YOU ARE HERE").Contains("three"),
Contains("two"),
Contains("one"),
)
t.Views().Files().
IsFocused().
Lines(
Contains("UU").Contains("file"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("content2"),
Contains("======="),
Contains("content4"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑2 repo → master"))
t.Views().Commits().
Focus().
Lines(
Contains("five").IsSelected(),
Contains("four"),
Contains("three"),
Contains("two"),
Contains("one"),
).
SelectNextItem()
t.Views().Main().
Content(
Contains("-content2").
Contains("+content4"),
)
},
})

View File

@ -0,0 +1,101 @@
package sync
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pull with an interactive rebase strategy, where a conflict occurs. Also drop a commit while rebasing",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file", "content1")
shell.Commit("one")
shell.UpdateFileAndAdd("file", "content2")
shell.Commit("two")
shell.EmptyCommit("three")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.HardReset("HEAD^^")
shell.UpdateFileAndAdd("file", "content4")
shell.Commit("four")
shell.EmptyCommit("five")
shell.SetConfig("pull.rebase", "interactive")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("five"),
Contains("four"),
Contains("one"),
)
t.Views().Status().Content(Contains("↓2 repo → master"))
t.Views().Files().
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Views().Commits().
Focus().
Lines(
Contains("pick").Contains("five").IsSelected(),
Contains("YOU ARE HERE").Contains("three"),
Contains("two"),
Contains("one"),
).
Press(keys.Universal.Remove).
Lines(
Contains("drop").Contains("five").IsSelected(),
Contains("YOU ARE HERE").Contains("three"),
Contains("two"),
Contains("one"),
)
t.Views().Files().
Focus().
Lines(
Contains("UU").Contains("file"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("content2"),
Contains("======="),
Contains("content4"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑1 repo → master"))
t.Views().Commits().
Focus().
Lines(
Contains("four").IsSelected(),
Contains("three"),
Contains("two"),
Contains("one"),
)
t.Views().Main().
Content(
Contains("-content2").
Contains("+content4"),
)
},
})

View File

@ -17,6 +17,8 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
"github.com/jesseduffield/lazygit/pkg/integration/tests/misc"
"github.com/jesseduffield/lazygit/pkg/integration/tests/patch_building"
"github.com/jesseduffield/lazygit/pkg/integration/tests/reflog"
"github.com/jesseduffield/lazygit/pkg/integration/tests/staging"
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
"github.com/jesseduffield/lazygit/pkg/integration/tests/submodule"
"github.com/jesseduffield/lazygit/pkg/integration/tests/sync"
@ -37,6 +39,8 @@ var tests = []*components.IntegrationTest{
branch.RebaseAndDrop,
branch.RebaseDoesNotAutosquash,
branch.Reset,
branch.ResetUpstream,
branch.SetUpstream,
branch.Suggestions,
cherry_pick.CherryPick,
cherry_pick.CherryPickConflicts,
@ -45,8 +49,11 @@ var tests = []*components.IntegrationTest{
commit.CreateTag,
commit.DiscardOldFileChange,
commit.NewBranch,
commit.ResetAuthor,
commit.Revert,
commit.RevertMerge,
commit.Search,
commit.SetAuthor,
commit.StageRangeOfLines,
commit.Staged,
commit.StagedWithoutHooks,
@ -87,6 +94,11 @@ var tests = []*components.IntegrationTest{
misc.ConfirmOnQuit,
misc.InitialOpen,
patch_building.CopyPatchToClipboard,
reflog.Checkout,
reflog.CherryPick,
reflog.Patch,
reflog.Reset,
staging.Search,
stash.Apply,
stash.ApplyPatch,
stash.CreateBranch,
@ -109,6 +121,12 @@ var tests = []*components.IntegrationTest{
sync.ForcePushMultipleUpstream,
sync.Pull,
sync.PullAndSetUpstream,
sync.PullMerge,
sync.PullMergeConflict,
sync.PullRebase,
sync.PullRebaseConflict,
sync.PullRebaseInteractiveConflict,
sync.PullRebaseInteractiveConflictDrop,
sync.Push,
sync.PushAndAutoSetUpstream,
sync.PushAndSetUpstream,

View File

@ -1 +0,0 @@
ref: refs/heads/master

View File

@ -1,8 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/pullMerge/actual/./repo

View File

@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.

View File

@ -1,7 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store

View File

@ -1,2 +0,0 @@
x�ΝA
ƒ0@Ρ®s�ΩJF§“))Ές1™PΑ!")ΨΫΧ#tϋyπS5[ ρ¥ν�ΰ•Sρ‘ηπPΙD�ΒY°‹XΝΤg¦Σ½sρΣήu‡q‚η8½τ�¶­zKΥ@&ιIΈ"zοΞzN�ώΙ�}Λ²*Ί6%,ε

View File

@ -1,2 +0,0 @@
x�خA
آ0@Qط9E��ج$��D��z���`ءظR"وٍٍ�~�قدkkK��وشwUً*�ِبا�4!s�عVaG>ج9$4[��ص-�P�H$`�ذU�Z5W)nb�0�&e5��ًn�ر^�ّ�����^ن��,2EOQXٌ���ي�'7ٍ[������9%

View File

@ -1,2 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
291b985e75f255f9947f064aee9e1f37af1a930d refs/heads/master

View File

@ -1 +0,0 @@
291b985e75f255f9947f064aee9e1f37af1a930d branch 'master' of ../origin

View File

@ -1 +0,0 @@
ref: refs/heads/master

View File

@ -1 +0,0 @@
673a4237450c6ea2a27b18f1d7a3c9293c5606ea

View File

@ -1,18 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
email = CI@example.com
name = CI
[remote "origin"]
url = ../origin
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[pull]
rebase = false

View File

@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.

View File

@ -1,7 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store

View File

@ -1,7 +0,0 @@
0000000000000000000000000000000000000000 224786fb3e4a16b22b4e2b43fe01d7797491adad CI <CI@example.com> 1648348767 +1100 commit (initial): myfile1
224786fb3e4a16b22b4e2b43fe01d7797491adad 82422401226cbf89b60b7ba3c6d4fa74781250c9 CI <CI@example.com> 1648348767 +1100 commit: myfile2
82422401226cbf89b60b7ba3c6d4fa74781250c9 0d5dd7784063912fe3efeaf7d2b6782019ee9e6e CI <CI@example.com> 1648348767 +1100 commit: myfile3
0d5dd7784063912fe3efeaf7d2b6782019ee9e6e 291b985e75f255f9947f064aee9e1f37af1a930d CI <CI@example.com> 1648348767 +1100 commit: myfile4
291b985e75f255f9947f064aee9e1f37af1a930d 82422401226cbf89b60b7ba3c6d4fa74781250c9 CI <CI@example.com> 1648348767 +1100 reset: moving to HEAD~2
82422401226cbf89b60b7ba3c6d4fa74781250c9 673a4237450c6ea2a27b18f1d7a3c9293c5606ea CI <CI@example.com> 1648348767 +1100 commit: myfile4
673a4237450c6ea2a27b18f1d7a3c9293c5606ea a61316509295a5644a82e38e8bd455422fe477c5 CI <CI@example.com> 1648348768 +1100 pull --no-edit: Merge made by the 'recursive' strategy.

View File

@ -1,7 +0,0 @@
0000000000000000000000000000000000000000 224786fb3e4a16b22b4e2b43fe01d7797491adad CI <CI@example.com> 1648348767 +1100 commit (initial): myfile1
224786fb3e4a16b22b4e2b43fe01d7797491adad 82422401226cbf89b60b7ba3c6d4fa74781250c9 CI <CI@example.com> 1648348767 +1100 commit: myfile2
82422401226cbf89b60b7ba3c6d4fa74781250c9 0d5dd7784063912fe3efeaf7d2b6782019ee9e6e CI <CI@example.com> 1648348767 +1100 commit: myfile3
0d5dd7784063912fe3efeaf7d2b6782019ee9e6e 291b985e75f255f9947f064aee9e1f37af1a930d CI <CI@example.com> 1648348767 +1100 commit: myfile4
291b985e75f255f9947f064aee9e1f37af1a930d 82422401226cbf89b60b7ba3c6d4fa74781250c9 CI <CI@example.com> 1648348767 +1100 reset: moving to HEAD~2
82422401226cbf89b60b7ba3c6d4fa74781250c9 673a4237450c6ea2a27b18f1d7a3c9293c5606ea CI <CI@example.com> 1648348767 +1100 commit: myfile4
673a4237450c6ea2a27b18f1d7a3c9293c5606ea a61316509295a5644a82e38e8bd455422fe477c5 CI <CI@example.com> 1648348768 +1100 pull --no-edit: Merge made by the 'recursive' strategy.

View File

@ -1 +0,0 @@
0000000000000000000000000000000000000000 291b985e75f255f9947f064aee9e1f37af1a930d CI <CI@example.com> 1648348767 +1100 fetch origin: storing head

View File

@ -1,2 +0,0 @@
x�ΝA
ƒ0@Ρ®s�ΩJF§“))Ές1™PΑ!")ΨΫΧ#tϋyπS5[ ρ¥ν�ΰ•Sρ‘ηπPΙD�ΒY°‹XΝΤg¦Σ½sρΣήu‡q‚η8½τ�¶­zKΥ@&ιIΈ"zοΞzN�ώΙ�}Λ²*Ί6%,ε

View File

@ -1,2 +0,0 @@
x�خA
آ0@Qط9E��ج$��D��z���`ءظR"وٍٍ�~�قدkkK��وشwUً*�ِبا�4!s�عVaG>ج9$4[��ص-�P�H$`�ذU�Z5W)nb�0�&e5��ًn�ر^�ّ�����^ن��,2EOQXٌ���ي�'7ٍ[������9%

View File

@ -1 +0,0 @@
a61316509295a5644a82e38e8bd455422fe477c5

View File

@ -1 +0,0 @@
291b985e75f255f9947f064aee9e1f37af1a930d

View File

@ -1 +0,0 @@
test1

View File

@ -1 +0,0 @@
test2

View File

@ -1 +0,0 @@
test3

View File

@ -1 +0,0 @@
test4

View File

@ -1 +0,0 @@
{"KeyEvents":[{"Timestamp":537,"Mod":0,"Key":256,"Ch":112},{"Timestamp":1401,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}

View File

@ -1,42 +0,0 @@
#!/bin/sh
set -e
set -e
cd $1
git init
git config user.email "CI@example.com"
git config user.name "CI"
echo test1 > myfile1
git add .
git commit -am "myfile1"
echo test2 > myfile2
git add .
git commit -am "myfile2"
echo test3 > myfile3
git add .
git commit -am "myfile3"
echo test4 > myfile4
git add .
git commit -am "myfile4"
cd ..
git clone --bare ./repo origin
cd repo
git reset --hard HEAD~2
echo test4 > myfile4
git add .
git commit -am "myfile4"
git remote add origin ../origin
git fetch origin
git branch --set-upstream-to=origin/master master
git config pull.rebase false

View File

@ -1 +0,0 @@
{ "description": "When user has configured pull with merge, ensure a merge commit is created upon pull", "speed": 10 }

View File

@ -1 +0,0 @@
ref: refs/heads/master

View File

@ -1,8 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/pullMergeConflict/actual/./repo

View File

@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.

View File

@ -1,7 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
.DS_Store

View File

@ -1,2 +0,0 @@
xŤÎA
Â0@Q×9Eö‚d’É$ˇ«cšÎ`ÁŘR"čííÜ~Ţâ×µµĄ[(xę»�őJ�ĐE˛Ă�p˘�9D’DC¬ �Ťwyu[d§čQ„¦X<‚HU•ą*#&Ď™ćâÓlřÝën‡Ń^‡ń.nŰS.um7 „9`�”íŔ9sÔcŞËźÜ´Ż.OAó9w

View File

@ -1,2 +0,0 @@
x�ÍA
ƒ0@Ñ®sŠÙJF§“J\yŒ˜L¨à�")´·×#tûyðS5[ ñ¥íªà•Sñ‘—0¨d"Eá,ØE,�ê3S‰éÞ¹øi¯ºÃ4ÃcšGýF{ozKÕž€LÒÓ€AàŠè½;ë9iú'wö+ë¦è5",ß

View File

@ -1,2 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
29c0636a86cc64292b7a6b1083c2df10de9cde6c refs/heads/master

View File

@ -1,25 +0,0 @@
Merge branch 'master' of ../origin
# Conflicts:
# myfile4
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
# /Users/jesseduffieldduffield/go/src/github.com/jesseduffield/lazygit/test/integration/pullMergeConflict/actual/repo/.git/MERGE_HEAD
# and try again.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 2 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
#
# All conflicts fixed but you are still merging.
#
# Changes to be committed:
# new file: myfile3
# modified: myfile4
#

View File

@ -1 +0,0 @@
29c0636a86cc64292b7a6b1083c2df10de9cde6c branch 'master' of ../origin

View File

@ -1 +0,0 @@
ref: refs/heads/master

Some files were not shown because too many files have changed in this diff Show More