mirror of
https://github.com/dorny/paths-filter.git
synced 2026-07-07 06:45:38 +00:00
Add function to resolve ref to SHA
This commit is contained in:
parent
f3ceefdc7e
commit
62f774ae39
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user