| 1 | import { runGit } from '../exec/run-git.js'; |
| 2 | |
| 3 | export async function listRefs |
| 4 | const raw = |
| 5 | args: ['for-each-ref', |
| 6 | gitDir, |
| 7 | }); |
| 8 | return new Map |
| 9 | raw |
| 10 | .split('\n') |
| 11 | .filter(Boolean) |
| 12 | .map((line) |
| 13 | const [ref, |
| 14 | return [ref, |
| 15 | }), |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | /** Branch names, without `refs/heads/`. */ |
| 20 | export async function listBranches |
| 21 | const raw = |
| 22 | // `short` would print `heads/v1` for a branch that shares its name with a tag |
| 23 | args: ['for-each-ref', |
| 24 | gitDir, |
| 25 | }); |
| 26 | return raw.split |
| 27 | } |