Skip to content

Commit

Permalink
unescape another string
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Nov 21, 2019
1 parent bad06bb commit 3dd1daa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/commands/loading_remotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/commands/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3dd1daa

Please sign in to comment.