(
base_ref: str, head_ref: str, use_merge_base: bool
)
| 242 | |
| 243 | |
| 244 | def collect_commits( |
| 245 | base_ref: str, head_ref: str, use_merge_base: bool |
| 246 | ) -> list[CommitRecord]: |
| 247 | start_ref = base_ref |
| 248 | if use_merge_base: |
| 249 | start_ref = run_git('merge-base', base_ref, head_ref) |
| 250 | raw_log = run_git( |
| 251 | 'log', |
| 252 | '--reverse', |
| 253 | '--pretty=format:%H%x1f%s%x1f%an%x1e', |
| 254 | f'{start_ref}..{head_ref}', |
| 255 | ) |
| 256 | if not raw_log: |
| 257 | return [] |
| 258 | |
| 259 | commits = [] |
| 260 | for record in raw_log.split('\x1e'): |
| 261 | record = record.strip() |
| 262 | if not record: |
| 263 | continue |
| 264 | commit_hash, title, author = record.split('\x1f') |
| 265 | commits.append( |
| 266 | CommitRecord( |
| 267 | commit_hash=commit_hash, |
| 268 | title=title, |
| 269 | git_author=author, |
| 270 | pr_number=extract_pr_number(title), |
| 271 | ) |
| 272 | ) |
| 273 | return commits |
| 274 | |
| 275 | |
| 276 | class PullRequestCache: |
no test coverage detected