diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:17:18 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:17:18 +1100 |
commit | 3dd1daacdc99b7eb9c4828154c7ece436beb98f4 (patch) | |
tree | 36115b81a2d2b393666ffcd3bda36077316eb386 /pkg/commands | |
parent | bad06bb634917d0f4f21c4f54823cf5f2cc3c392 (diff) |
unescape another stringv0.11.2
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/loading_remotes.go | 3 | ||||
-rw-r--r-- | pkg/commands/os.go | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/pkg/commands/loading_remotes.go b/pkg/commands/loading_remotes.go index f4f1b4a01..a56e8571a 100644 --- a/pkg/commands/loading_remotes.go +++ b/pkg/commands/loading_remotes.go @@ -9,7 +9,8 @@ import ( func (c *GitCommand) GetRemotes() ([]*Remote, error) { // get remote branches - remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput("git for-each-ref --format='%%(refname:strip=2)' refs/remotes") + unescaped := "git for-each-ref --format='%(refname:strip=2)' refs/remotes" + remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(unescaped) if err != nil { return nil, err } diff --git a/pkg/commands/os.go b/pkg/commands/os.go index e421c4e6a..a9a5947d9 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -59,8 +59,11 @@ func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd) { } // RunCommandWithOutput wrapper around commands returning their output and error -// NOTE: because this takes a format string followed by format args, you'll need -// to escape any percentage signs via '%%'. +// NOTE: If you don't pass any formatArgs we'll just use the command directly, +// however there's a bizarre compiler error/warning when you pass in a formatString +// with a percent sign because it thinks it's supposed to be a formatString when +// in that case it's not. To get around that error you'll need to define the string +// in a variable and pass the variable into RunCommandWithOutput. func (c *OSCommand) RunCommandWithOutput(formatString string, formatArgs ...interface{}) (string, error) { command := formatString if formatArgs != nil { |