mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Merge 66308f3095 into 8924bca76f
This commit is contained in:
commit
10a024b564
|
|
@ -237,7 +237,7 @@ func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *ContextCommon
|
|||
return self
|
||||
}
|
||||
|
||||
func (self *LocalCommitsContext) CanRebase() bool {
|
||||
func (self *LocalCommitsContext) CanRebase(currentBranch *models.Branch) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
|
|||
}
|
||||
}
|
||||
|
||||
func (self *ReflogCommitsContext) CanRebase() bool {
|
||||
func (self *ReflogCommitsContext) CanRebase(currentBranch *models.Branch) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func NewStashContext(
|
|||
}
|
||||
}
|
||||
|
||||
func (self *StashContext) CanRebase() bool {
|
||||
func (self *StashContext) CanRebase(currentBranch *models.Branch) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ func (self *SubCommitsViewModel) GetShowBranchHeads() bool {
|
|||
return self.showBranchHeads
|
||||
}
|
||||
|
||||
func (self *SubCommitsContext) CanRebase() bool {
|
||||
return false
|
||||
func (self *SubCommitsContext) CanRebase(currentBranch *models.Branch) bool {
|
||||
return self.GetRef() == currentBranch
|
||||
}
|
||||
|
||||
func (self *SubCommitsContext) GetSelectedRef() models.Ref {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ var _ types.IController = &SwitchToDiffFilesController{}
|
|||
|
||||
type CanSwitchToDiffFiles interface {
|
||||
types.IListContext
|
||||
CanRebase() bool
|
||||
CanRebase(currentBranch *models.Branch) bool
|
||||
GetSelectedRef() models.Ref
|
||||
GetSelectedRefRangeForDiffFiles() *types.RefRange
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ func (self *SwitchToDiffFilesController) enter() error {
|
|||
refsRange := self.context.GetSelectedRefRangeForDiffFiles()
|
||||
commitFilesContext := self.c.Contexts().CommitFiles
|
||||
|
||||
canRebase := self.context.CanRebase()
|
||||
canRebase := self.context.CanRebase(self.c.Helpers().Refs.GetCheckedOutRef())
|
||||
if canRebase {
|
||||
if self.c.Modes().Diffing.Active() {
|
||||
if self.c.Modes().Diffing.Ref != ref.RefName() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package patch_building
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var MoveToIndexFromSubcommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit of the current branch to the index",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("file1", "file1 content\n")
|
||||
shell.CreateFileAndAdd("file2", "file2 content\n")
|
||||
shell.Commit("first commit")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("master").IsSelected(),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("first commit").IsSelected(),
|
||||
).
|
||||
PressEnter()
|
||||
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Equals("▼ /").IsSelected(),
|
||||
Contains("file1"),
|
||||
Contains("file2"),
|
||||
).
|
||||
SelectNextItem().
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().Secondary().Content(Contains("+file1 content"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Move patch out into index"))
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("A").Contains("file1"),
|
||||
).
|
||||
Focus()
|
||||
|
||||
t.Views().Main().
|
||||
Content(Contains("file1 content"))
|
||||
},
|
||||
})
|
||||
|
|
@ -373,6 +373,7 @@ var tests = []*components.IntegrationTest{
|
|||
patch_building.MoveToEarlierCommitFromAddedFile,
|
||||
patch_building.MoveToIndex,
|
||||
patch_building.MoveToIndexFromAddedFileWithConflict,
|
||||
patch_building.MoveToIndexFromSubcommit,
|
||||
patch_building.MoveToIndexPartOfAdjacentAddedLines,
|
||||
patch_building.MoveToIndexPartial,
|
||||
patch_building.MoveToIndexWithConflict,
|
||||
|
|
|
|||
Loading…
Reference in a new issue