mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-29 00:51:35 +02:00
refactor
This commit is contained in:
pkg
commands
gui
branches_panel.gocherry_picking.gocommand_log_panel.gocommit_files_panel.gocommit_message_panel.gocommits_panel.gocustom_commands.godiscard_changes_menu_panel.gofiles_panel.gogit_flow.goglobal_handlers.gogpg.gogui.goline_by_line_panel.gomerge_panel.gopatch_options_panel.gopull_request_menu_panel.gorebase_options_panel.goreflog_panel.goremote_branches_panel.goremotes_panel.goreset_menu_panel.gostaging_panel.gostash_panel.gosub_commits_panel.gosubmodules_panel.gotags_panel.goundoing.goworkspace_reset_options_panel.go
i18n
@ -21,9 +21,8 @@ type ICmdObjBuilder interface {
|
||||
}
|
||||
|
||||
type CmdObjBuilder struct {
|
||||
runner ICmdObjRunner
|
||||
logCmdObj func(ICmdObj)
|
||||
platform *Platform
|
||||
runner ICmdObjRunner
|
||||
platform *Platform
|
||||
}
|
||||
|
||||
// poor man's version of explicitly saying that struct X implements interface Y
|
||||
@ -76,8 +75,27 @@ func (self *CmdObjBuilder) CloneWithNewRunner(decorate func(ICmdObjRunner) ICmdO
|
||||
decoratedRunner := decorate(self.runner)
|
||||
|
||||
return &CmdObjBuilder{
|
||||
runner: decoratedRunner,
|
||||
logCmdObj: self.logCmdObj,
|
||||
platform: self.platform,
|
||||
runner: decoratedRunner,
|
||||
platform: self.platform,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *CmdObjBuilder) Quote(message string) string {
|
||||
var quote string
|
||||
if self.platform.OS == "windows" {
|
||||
quote = `\"`
|
||||
message = strings.NewReplacer(
|
||||
`"`, `"'"'"`,
|
||||
`\"`, `\\"`,
|
||||
).Replace(message)
|
||||
} else {
|
||||
quote = `"`
|
||||
message = strings.NewReplacer(
|
||||
`\`, `\\`,
|
||||
`"`, `\"`,
|
||||
`$`, `\$`,
|
||||
"`", "\\`",
|
||||
).Replace(message)
|
||||
}
|
||||
return quote + message + quote
|
||||
}
|
||||
|
Reference in New Issue
Block a user