13
0
Fork 0
mirror of https://github.com/dorny/paths-filter.git synced 2026-06-28 20:30:43 +00:00

Add function to resolve ref to SHA

This commit is contained in:
Zydney Ambat 2026-06-25 07:45:01 +10:00 committed by GitHub
parent f3ceefdc7e
commit 62f774ae39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -198,6 +198,11 @@ export function isGitSha(ref: string): boolean {
return /^[a-z0-9]{40}$/.test(ref)
}
export async function resolveRefToSha(ref: string): Promise<string> {
const output = (await getExecOutput('git', ['rev-parse', ref])).stdout.trim()
return output
}
async function hasCommit(ref: string): Promise<boolean> {
return (await getExecOutput('git', ['cat-file', '-e', `${ref}^{commit}`], {ignoreReturnCode: true})).exitCode === 0
}