mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-02 23:27:32 +02:00
Clear cherry-picked commits after pasting
It can be tedious after each cherry-pick opearation to clear the selection by pressing escape in order for lazygit to stop displaying info about copied commits. Also, it seems to be a rare case to cherry-pick commits to more than one destination. The simplest solution to address this issue is to clear the selection upon paste. The only exception is a merge conflict. Initially, I wanted to clear selected commits in this scenario too. During a discussion we found out that it may be convenient to have the copied commits still around. Aborting the rebase and pasting the commits in the middle of a branch can be a valid use case.
This commit is contained in:
parent
761c77f5a2
commit
ee173ff7c9
@ -90,15 +90,36 @@ func (self *CherryPickHelper) Paste() error {
|
|||||||
if err := self.c.Git().Rebase.CherryPickCommitsDuringRebase(self.getData().CherryPickedCommits); err != nil {
|
if err := self.c.Git().Rebase.CherryPickCommitsDuringRebase(self.getData().CherryPickedCommits); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return self.c.Refresh(types.RefreshOptions{
|
err = self.c.Refresh(types.RefreshOptions{
|
||||||
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
|
Mode: types.SYNC, Scope: []types.RefreshableView{types.REBASE_COMMITS},
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func(gocui.Task) error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.CherryPick)
|
self.c.LogAction(self.c.Tr.Actions.CherryPick)
|
||||||
err := self.c.Git().Rebase.CherryPickCommits(self.getData().CherryPickedCommits)
|
err := self.c.Git().Rebase.CherryPickCommits(self.getData().CherryPickedCommits)
|
||||||
return self.rebaseHelper.CheckMergeOrRebase(err)
|
err = self.rebaseHelper.CheckMergeOrRebase(err)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're in an interactive rebase at this point, it must
|
||||||
|
// be because there were conflicts. Don't clear the copied
|
||||||
|
// commits in this case, since we might want to abort and
|
||||||
|
// try pasting them again.
|
||||||
|
isInRebase, err = self.c.Git().Status.IsInInteractiveRebase()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isInRebase {
|
||||||
|
return self.Reset()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -59,26 +59,25 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Contains("base"),
|
Contains("base"),
|
||||||
).
|
).
|
||||||
Press(keys.Commits.PasteCommits).
|
Press(keys.Commits.PasteCommits).
|
||||||
|
Tap(func() {
|
||||||
|
// cherry-picked commits will be deleted after confirmation
|
||||||
|
t.Views().Information().Content(Contains("2 commits copied"))
|
||||||
|
}).
|
||||||
Tap(func() {
|
Tap(func() {
|
||||||
t.ExpectPopup().Alert().
|
t.ExpectPopup().Alert().
|
||||||
Title(Equals("Cherry-pick")).
|
Title(Equals("Cherry-pick")).
|
||||||
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
|
Tap(func() {
|
||||||
|
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||||
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("four"),
|
Contains("four"),
|
||||||
Contains("three"),
|
Contains("three"),
|
||||||
Contains("two"),
|
Contains("two"),
|
||||||
Contains("one"),
|
Contains("one"),
|
||||||
Contains("base"),
|
Contains("base"),
|
||||||
).
|
)
|
||||||
Tap(func() {
|
|
||||||
// we need to manually exit out of cherry pick mode
|
|
||||||
t.Views().Information().Content(Contains("2 commits copied"))
|
|
||||||
}).
|
|
||||||
PressEscape().
|
|
||||||
Tap(func() {
|
|
||||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -54,6 +54,10 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
|
|
||||||
t.Common().AcknowledgeConflicts()
|
t.Common().AcknowledgeConflicts()
|
||||||
|
|
||||||
|
// cherry pick selection is not cleared when there are conflicts, so that the user
|
||||||
|
// is able to abort and try again without having to re-copy the commits
|
||||||
|
t.Views().Information().Content(Contains("2 commits copied"))
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
IsFocused().
|
IsFocused().
|
||||||
SelectedLine(Contains("file")).
|
SelectedLine(Contains("file")).
|
||||||
|
@ -68,6 +68,9 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
|
Tap(func() {
|
||||||
|
t.Views().Information().Content(DoesNotContain("commit copied"))
|
||||||
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("pick CI two"),
|
Contains("pick CI two"),
|
||||||
Contains("pick CI three"),
|
Contains("pick CI three"),
|
||||||
|
@ -66,20 +66,15 @@ var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
|
Tap(func() {
|
||||||
|
t.Views().Information().Content(DoesNotContain("commits copied"))
|
||||||
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
Contains("four"),
|
Contains("four"),
|
||||||
Contains("three"),
|
Contains("three"),
|
||||||
Contains("two"),
|
Contains("two"),
|
||||||
Contains("one"),
|
Contains("one"),
|
||||||
Contains("base"),
|
Contains("base"),
|
||||||
).
|
)
|
||||||
Tap(func() {
|
|
||||||
// we need to manually exit out of cherry pick mode
|
|
||||||
t.Views().Information().Content(Contains("2 commits copied"))
|
|
||||||
}).
|
|
||||||
PressEscape().
|
|
||||||
Tap(func() {
|
|
||||||
t.Views().Information().Content(DoesNotContain("commits copied"))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user