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:
parent
f3ceefdc7e
commit
62f774ae39
1 changed files with 5 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue