( cwd: string, )
| 86 | * a worktree. |
| 87 | */ |
| 88 | export async function readLastFetchTime( |
| 89 | cwd: string, |
| 90 | ): Promise<Date | undefined> { |
| 91 | const gitDir = await getGitDir(cwd) |
| 92 | if (!gitDir) return undefined |
| 93 | const commonDir = await getCommonDir(gitDir) |
| 94 | const [local, common] = await Promise.all([ |
| 95 | mtimeOrUndefined(join(gitDir, 'FETCH_HEAD')), |
| 96 | commonDir |
| 97 | ? mtimeOrUndefined(join(commonDir, 'FETCH_HEAD')) |
| 98 | : Promise.resolve(undefined), |
| 99 | ]) |
| 100 | if (local && common) return local > common ? local : common |
| 101 | return local ?? common |
| 102 | } |
| 103 | |
| 104 | async function mtimeOrUndefined(p: string): Promise<Date | undefined> { |
| 105 | try { |
no test coverage detected