mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Change customCommand fields to pointers
This allows us to tell whether they appear in the user's config file, which we will need later in this branch.
This commit is contained in:
@ -619,7 +619,8 @@ type CustomCommand struct {
|
|||||||
// The command to run (using Go template syntax for placeholder values)
|
// The command to run (using Go template syntax for placeholder values)
|
||||||
Command string `yaml:"command" jsonschema:"example=git fetch {{.Form.Remote}} {{.Form.Branch}} && git checkout FETCH_HEAD"`
|
Command string `yaml:"command" jsonschema:"example=git fetch {{.Form.Remote}} {{.Form.Branch}} && git checkout FETCH_HEAD"`
|
||||||
// If true, run the command in a subprocess (e.g. if the command requires user input)
|
// If true, run the command in a subprocess (e.g. if the command requires user input)
|
||||||
Subprocess bool `yaml:"subprocess"`
|
// [dev] Pointer to bool so that we can distinguish unset (nil) from false.
|
||||||
|
Subprocess *bool `yaml:"subprocess"`
|
||||||
// A list of prompts that will request user input before running the final command
|
// A list of prompts that will request user input before running the final command
|
||||||
Prompts []CustomCommandPrompt `yaml:"prompts"`
|
Prompts []CustomCommandPrompt `yaml:"prompts"`
|
||||||
// Text to display while waiting for command to finish
|
// Text to display while waiting for command to finish
|
||||||
@ -627,13 +628,16 @@ type CustomCommand struct {
|
|||||||
// Label for the custom command when displayed in the keybindings menu
|
// Label for the custom command when displayed in the keybindings menu
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
// If true, stream the command's output to the Command Log panel
|
// If true, stream the command's output to the Command Log panel
|
||||||
Stream bool `yaml:"stream"`
|
// [dev] Pointer to bool so that we can distinguish unset (nil) from false.
|
||||||
|
Stream *bool `yaml:"stream"`
|
||||||
// If true, show the command's output in a popup within Lazygit
|
// If true, show the command's output in a popup within Lazygit
|
||||||
ShowOutput bool `yaml:"showOutput"`
|
// [dev] Pointer to bool so that we can distinguish unset (nil) from false.
|
||||||
|
ShowOutput *bool `yaml:"showOutput"`
|
||||||
// The title to display in the popup panel if showOutput is true. If left unset, the command will be used as the title.
|
// The title to display in the popup panel if showOutput is true. If left unset, the command will be used as the title.
|
||||||
OutputTitle string `yaml:"outputTitle"`
|
OutputTitle string `yaml:"outputTitle"`
|
||||||
// Actions to take after the command has completed
|
// Actions to take after the command has completed
|
||||||
After CustomCommandAfterHook `yaml:"after"`
|
// [dev] Pointer so that we can tell whether it appears in the config file
|
||||||
|
After *CustomCommandAfterHook `yaml:"after"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomCommandPrompt struct {
|
type CustomCommandPrompt struct {
|
||||||
|
@ -261,7 +261,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
|
|||||||
|
|
||||||
cmdObj := self.c.OS().Cmd.NewShell(cmdStr)
|
cmdObj := self.c.OS().Cmd.NewShell(cmdStr)
|
||||||
|
|
||||||
if customCommand.Subprocess {
|
if customCommand.Subprocess != nil && *customCommand.Subprocess {
|
||||||
return self.c.RunSubprocessAndRefresh(cmdObj)
|
return self.c.RunSubprocessAndRefresh(cmdObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
|
|||||||
return self.c.WithWaitingStatus(loadingText, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(loadingText, func(gocui.Task) error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.CustomCommand)
|
self.c.LogAction(self.c.Tr.Actions.CustomCommand)
|
||||||
|
|
||||||
if customCommand.Stream {
|
if customCommand.Stream != nil && *customCommand.Stream {
|
||||||
cmdObj.StreamOutput()
|
cmdObj.StreamOutput()
|
||||||
}
|
}
|
||||||
output, err := cmdObj.RunWithOutput()
|
output, err := cmdObj.RunWithOutput()
|
||||||
@ -283,14 +283,14 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if customCommand.After.CheckForConflicts {
|
if customCommand.After != nil && customCommand.After.CheckForConflicts {
|
||||||
return self.mergeAndRebaseHelper.CheckForConflicts(err)
|
return self.mergeAndRebaseHelper.CheckForConflicts(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if customCommand.ShowOutput {
|
if customCommand.ShowOutput != nil && *customCommand.ShowOutput {
|
||||||
if strings.TrimSpace(output) == "" {
|
if strings.TrimSpace(output) == "" {
|
||||||
output = self.c.Tr.EmptyOutput
|
output = self.c.Tr.EmptyOutput
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ var CheckForConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Key: "m",
|
Key: "m",
|
||||||
Context: "localBranches",
|
Context: "localBranches",
|
||||||
Command: "git merge {{ .SelectedLocalBranch.Name | quote }}",
|
Command: "git merge {{ .SelectedLocalBranch.Name | quote }}",
|
||||||
After: config.CustomCommandAfterHook{
|
After: &config.CustomCommandAfterHook{
|
||||||
CheckForConflicts: true,
|
CheckForConflicts: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -15,18 +15,19 @@ var ShowOutputInPanel = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.EmptyCommit("my change")
|
shell.EmptyCommit("my change")
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {
|
SetupConfig: func(cfg *config.AppConfig) {
|
||||||
|
trueVal := true
|
||||||
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
|
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
|
||||||
{
|
{
|
||||||
Key: "X",
|
Key: "X",
|
||||||
Context: "commits",
|
Context: "commits",
|
||||||
Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
|
Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
|
||||||
ShowOutput: true,
|
ShowOutput: &trueVal,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: "Y",
|
Key: "Y",
|
||||||
Context: "commits",
|
Context: "commits",
|
||||||
Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
|
Command: "printf '%s' '{{ .SelectedLocalCommit.Name }}'",
|
||||||
ShowOutput: true,
|
ShowOutput: &trueVal,
|
||||||
OutputTitle: "Subject of commit {{ .SelectedLocalCommit.Hash }}",
|
OutputTitle: "Subject of commit {{ .SelectedLocalCommit.Hash }}",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user