stefanwille / git-branch-delete

Interactive command line tool that makes it comfortable to delete several Git branches at once.
72 stars 9 forks source link

Quote branch name in delete command #8

Closed gabrielmaldi closed 2 years ago

gabrielmaldi commented 2 years ago

Fixes error when deleting, for example, a branch with parentheses () in its name:

git branch -D my/branch(test)
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `git branch -D my/branch(test)'
node:internal/errors:856
  const err = new Error(message);
              ^

Error: Command failed: git branch -D my/branch(test)
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `git branch -D my/branch(test)'

    at checkExecSyncError (node:child_process:841:11)
    at Object.execSync (node:child_process:912:15)
    at deleteBranches (/usr/local/lib/node_modules/git-branch-delete/build/git-branch-delete.js:125:36)
    at /usr/local/lib/node_modules/git-branch-delete/build/git-branch-delete.js:157:17
    at step (/usr/local/lib/node_modules/git-branch-delete/build/git-branch-delete.js:34:23)
    at Object.next (/usr/local/lib/node_modules/git-branch-delete/build/git-branch-delete.js:15:53)
    at fulfilled (/usr/local/lib/node_modules/git-branch-delete/build/git-branch-delete.js:6:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 2,
  signal: null,
  output: [
    null,
    '',
    "/bin/sh: -c: line 0: syntax error near unexpected token `('\n" +
      "/bin/sh: -c: line 0: `git branch -D my/branch(test)'\n"
  ],
  pid: 96153,
  stdout: '',
  stderr: "/bin/sh: -c: line 0: syntax error near unexpected token `('\n" +
    "/bin/sh: -c: line 0: `git branch -D my/branch(test)'\n"
}
stefanwille commented 2 years ago

Thank you!