| 1 | import { runGit } from '../exec/run-git.js'; |
| 2 | |
| 3 | /** Whether git accepts `name` as a branch or tag. Leading dashes and `HEAD` are refused too, so a name can never reach git as a flag or shadow the symbolic ref. */ |
| 4 | export async function isValidRefName |
| 5 | namespace: 'heads |
| 6 | name: string, |
| 7 | ) { |
| 8 | if (name.startsWith |
| 9 | return runGit({ |
| 10 | args: ['check-ref-format', |
| 11 | gitDir: '.', |
| 12 | }).then( |
| 13 | () => true, |
| 14 | () => false, |
| 15 | ); |
| 16 | } |