( git: ReturnType<typeof simpleGit>, localBranches: string[], )
| 267 | }; |
| 268 | |
| 269 | async function getLocalBranchesWithDates( |
| 270 | git: ReturnType<typeof simpleGit>, |
| 271 | localBranches: string[], |
| 272 | ): Promise<Array<{ branch: string; lastCommitDate: number }>> { |
| 273 | try { |
| 274 | const branchInfo = await git.raw([ |
| 275 | "for-each-ref", |
| 276 | "--sort=-committerdate", |
| 277 | "--format=%(refname:short) %(committerdate:unix)", |
| 278 | "refs/heads/", |
| 279 | ]); |
| 280 | |
| 281 | const local: Array<{ branch: string; lastCommitDate: number }> = []; |
| 282 | for (const line of branchInfo.trim().split("\n")) { |
| 283 | if (!line) continue; |
| 284 | const lastSpaceIdx = line.lastIndexOf(" "); |
| 285 | const branch = line.substring(0, lastSpaceIdx); |
| 286 | const timestamp = Number.parseInt(line.substring(lastSpaceIdx + 1), 10); |
| 287 | if (localBranches.includes(branch)) { |
| 288 | local.push({ |
| 289 | branch, |
| 290 | lastCommitDate: timestamp * 1000, |
| 291 | }); |
| 292 | } |
| 293 | } |
| 294 | return local; |
| 295 | } catch { |
| 296 | return localBranches.map((branch) => ({ branch, lastCommitDate: 0 })); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | async function getDefaultBranch( |
| 301 | git: ReturnType<typeof simpleGit>, |
no outgoing calls
no test coverage detected