({
path,
refName,
}: {
path: string,
refName: string,
})
| 343 | }; |
| 344 | |
| 345 | export const getCommitHashForRefName = async ({ |
| 346 | path, |
| 347 | refName, |
| 348 | }: { |
| 349 | path: string, |
| 350 | refName: string, |
| 351 | }) => { |
| 352 | const git = createGitClientForPath(path); |
| 353 | |
| 354 | try { |
| 355 | // The `^{commit}` suffix is used to fully dereference the ref to a commit hash. |
| 356 | const rev = await git.revparse(`${refName}^{commit}`); |
| 357 | return rev; |
| 358 | |
| 359 | // @note: Was hitting errors when the repository is empty, |
| 360 | // so we're catching the error and returning undefined. |
| 361 | } catch (error: unknown) { |
| 362 | logger.debug(error); |
| 363 | return undefined; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * Gets the default branch name from the remote repository by querying what |
no test coverage detected