( projectId: string, limit?: number | undefined | null, )
| 96 | } |
| 97 | |
| 98 | export async function listProjectCommits( |
| 99 | projectId: string, |
| 100 | limit?: number | undefined | null, |
| 101 | ): Promise<ProjectCommitEntry[]> { |
| 102 | if (!(await isGitRepository(projectId))) { |
| 103 | return [] |
| 104 | } |
| 105 | |
| 106 | const normalizedLimit = Math.min(Math.max(limit ?? 50, 1), 200) |
| 107 | |
| 108 | let stdout = '' |
| 109 | |
| 110 | try { |
| 111 | ;({ stdout } = await runGitWithOptions( |
| 112 | projectId, |
| 113 | [ |
| 114 | 'log', |
| 115 | '-z', |
| 116 | `--max-count=${normalizedLimit}`, |
| 117 | '--decorate=short', |
| 118 | `--format=${COMMIT_PRETTY_FORMAT}`, |
| 119 | ], |
| 120 | { |
| 121 | timeout: 10_000, |
| 122 | maxBuffer: 1024 * 1024 * 4, |
| 123 | }, |
| 124 | )) |
| 125 | } catch { |
| 126 | return [] |
| 127 | } |
| 128 | |
| 129 | return parseCommitEntries(stdout) |
| 130 | } |
no test coverage detected