Resolve the commit to use for the clone. Parameters ---------- config : CloneConfig The configuration for cloning the repository. token : str | None GitHub personal access token (PAT) for accessing private repositories. Returns ------- str The co
(config: CloneConfig, token: str | None)
| 348 | |
| 349 | |
| 350 | async def resolve_commit(config: CloneConfig, token: str | None) -> str: |
| 351 | """Resolve the commit to use for the clone. |
| 352 | |
| 353 | Parameters |
| 354 | ---------- |
| 355 | config : CloneConfig |
| 356 | The configuration for cloning the repository. |
| 357 | token : str | None |
| 358 | GitHub personal access token (PAT) for accessing private repositories. |
| 359 | |
| 360 | Returns |
| 361 | ------- |
| 362 | str |
| 363 | The commit SHA. |
| 364 | |
| 365 | """ |
| 366 | if config.commit: |
| 367 | commit = config.commit |
| 368 | elif config.tag: |
| 369 | commit = await _resolve_ref_to_sha(config.url, pattern=f"refs/tags/{config.tag}*", token=token) |
| 370 | elif config.branch: |
| 371 | commit = await _resolve_ref_to_sha(config.url, pattern=f"refs/heads/{config.branch}", token=token) |
| 372 | else: |
| 373 | commit = await _resolve_ref_to_sha(config.url, pattern="HEAD", token=token) |
| 374 | return commit |
| 375 | |
| 376 | |
| 377 | async def _resolve_ref_to_sha(url: str, pattern: str, token: str | None = None) -> str: |
no test coverage detected