(repoPath: string, limit: number, afterCommit?: string)
| 120 | const userInputId = 'commit-picker' |
| 121 | |
| 122 | function getCommits(repoPath: string, limit: number, afterCommit?: string): CommitInfo[] { |
| 123 | const gitArgs = [ |
| 124 | 'log', |
| 125 | '--pretty=format:%H|%an|%ad|%s', |
| 126 | '--date=iso', |
| 127 | '-n', |
| 128 | limit.toString(), |
| 129 | ] |
| 130 | |
| 131 | // If afterCommit is specified, start from that commit's parent |
| 132 | if (afterCommit) { |
| 133 | gitArgs.push(`${afterCommit}^`) // Start from the parent of the specified commit |
| 134 | } |
| 135 | |
| 136 | const gitLogOutput = execFileSync( |
| 137 | 'git', |
| 138 | gitArgs, |
| 139 | { cwd: repoPath, encoding: 'utf-8' }, |
| 140 | ) |
| 141 | |
| 142 | const lines = gitLogOutput.split('\n').filter((line) => line.trim() !== '') |
| 143 | |
| 144 | return lines.map((line) => { |
| 145 | const [sha, author, date, ...messageParts] = line.split('|') |
| 146 | const message = messageParts.join('|') |
| 147 | |
| 148 | // Get stats for this commit |
| 149 | const statsOutput = execFileSync('git', ['show', '--stat', sha], { |
| 150 | cwd: repoPath, |
| 151 | encoding: 'utf-8', |
| 152 | }) |
| 153 | const stats = parseGitStats(statsOutput) |
| 154 | |
| 155 | return { |
| 156 | sha, |
| 157 | author, |
| 158 | date, |
| 159 | message, |
| 160 | stats, |
| 161 | } |
| 162 | }) |
| 163 | } |
| 164 | |
| 165 | function parseGitStats(statsOutput: string): { |
| 166 | filesChanged: number |
no test coverage detected