mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 16:22:24 +03:00
don't pass single commands directly to RunCommand (or equivalent function)
when it contains percentages.
This is a really strange one. It's a linting warning in my editor
and it doesn't stop me from compiling, but it breaks `go test`.
A basic file to reproduce what I'm talking about:
package main
import "fmt"
func main() {
notSprintf("test %s") // compiler complains here thinking %s needs a corresponding argument
}
func notSprintf(formatStr string, formatArgs ...interface{}) string {
if formatArgs != nil {
return formatStr
}
return fmt.Sprintf(formatStr, formatArgs...)
}
This commit is contained in:
@@ -47,7 +47,9 @@ func (b *BranchListBuilder) obtainCurrentBranch() *Branch {
|
||||
|
||||
func (b *BranchListBuilder) obtainReflogBranches() []*Branch {
|
||||
branches := make([]*Branch, 0)
|
||||
rawString, err := b.GitCommand.OSCommand.RunCommandWithOutput("git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD")
|
||||
// if we directly put this string in RunCommandWithOutput the compiler complains because it thinks it's a format string
|
||||
unescaped := "git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD"
|
||||
rawString, err := b.GitCommand.OSCommand.RunCommandWithOutput(unescaped)
|
||||
if err != nil {
|
||||
return branches
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user