mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Better prompt for discarding old file changes
Lazygit knows what kind of file change this is, so there doesn't have to be any "if" in the prompt text.
This commit is contained in:
@ -15,3 +15,11 @@ func (f *CommitFile) ID() string {
|
|||||||
func (f *CommitFile) Description() string {
|
func (f *CommitFile) Description() string {
|
||||||
return f.Name
|
return f.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *CommitFile) Added() bool {
|
||||||
|
return f.ChangeStatus == "A"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *CommitFile) Deleted() bool {
|
||||||
|
return f.ChangeStatus == "D"
|
||||||
|
}
|
||||||
|
@ -161,9 +161,16 @@ func (self *CommitFilesController) discard(node *filetree.CommitFileNode) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prompt := self.c.Tr.DiscardFileChangesPrompt
|
||||||
|
if node.File.Added() {
|
||||||
|
prompt = self.c.Tr.DiscardAddedFileChangesPrompt
|
||||||
|
} else if node.File.Deleted() {
|
||||||
|
prompt = self.c.Tr.DiscardDeletedFileChangesPrompt
|
||||||
|
}
|
||||||
|
|
||||||
return self.c.Confirm(types.ConfirmOpts{
|
return self.c.Confirm(types.ConfirmOpts{
|
||||||
Title: self.c.Tr.DiscardFileChangesTitle,
|
Title: self.c.Tr.DiscardFileChangesTitle,
|
||||||
Prompt: self.c.Tr.DiscardFileChangesPrompt,
|
Prompt: prompt,
|
||||||
HandleConfirm: func() error {
|
HandleConfirm: func() error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error {
|
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.DiscardOldFileChange)
|
self.c.LogAction(self.c.Tr.Actions.DiscardOldFileChange)
|
||||||
|
@ -268,6 +268,8 @@ type TranslationSet struct {
|
|||||||
DiscardOldFileChange string
|
DiscardOldFileChange string
|
||||||
DiscardFileChangesTitle string
|
DiscardFileChangesTitle string
|
||||||
DiscardFileChangesPrompt string
|
DiscardFileChangesPrompt string
|
||||||
|
DiscardAddedFileChangesPrompt string
|
||||||
|
DiscardDeletedFileChangesPrompt string
|
||||||
DiscardNotSupportedForDirectory string
|
DiscardNotSupportedForDirectory string
|
||||||
DisabledForGPG string
|
DisabledForGPG string
|
||||||
CreateRepo string
|
CreateRepo string
|
||||||
@ -955,7 +957,9 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
CheckoutCommitFile: "Checkout file",
|
CheckoutCommitFile: "Checkout file",
|
||||||
DiscardOldFileChange: "Discard this commit's changes to this file",
|
DiscardOldFileChange: "Discard this commit's changes to this file",
|
||||||
DiscardFileChangesTitle: "Discard file changes",
|
DiscardFileChangesTitle: "Discard file changes",
|
||||||
DiscardFileChangesPrompt: "Are you sure you want to discard this commit's changes to this file? If this file was created in this commit, it will be deleted",
|
DiscardFileChangesPrompt: "Are you sure you want to discard this commit's changes to this file?",
|
||||||
|
DiscardAddedFileChangesPrompt: "Are you sure you want to discard this commit's changes to this file? The file was added in this commit, so it will be deleted again.",
|
||||||
|
DiscardDeletedFileChangesPrompt: "Are you sure you want to discard this commit's changes to this file? The file was deleted in this commit, so it will reappear.",
|
||||||
DiscardNotSupportedForDirectory: "Discarding changes is not supported for entire directories. Please use a custom patch for this.",
|
DiscardNotSupportedForDirectory: "Discarding changes is not supported for entire directories. Please use a custom patch for this.",
|
||||||
DisabledForGPG: "Feature not available for users using GPG",
|
DisabledForGPG: "Feature not available for users using GPG",
|
||||||
CreateRepo: "Not in a git repository. Create a new git repository? (y/n): ",
|
CreateRepo: "Not in a git repository. Create a new git repository? (y/n): ",
|
||||||
|
@ -43,7 +43,7 @@ var DiscardOldFileChange = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
|
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Discard file changes")).
|
Title(Equals("Discard file changes")).
|
||||||
Content(Contains("Are you sure you want to discard this commit's changes to this file?")).
|
Content(Equals("Are you sure you want to discard this commit's changes to this file? The file was added in this commit, so it will be deleted again.")).
|
||||||
Confirm()
|
Confirm()
|
||||||
|
|
||||||
t.Views().CommitFiles().
|
t.Views().CommitFiles().
|
||||||
|
Reference in New Issue
Block a user