mirror of
https://gitea.com/actions/dorny-paths-filter.git
synced 2025-12-23 05:48:41 +00:00
* Support triggering from push event * Add self-test to build workflow * Update action metadata
27 lines
689 B
TypeScript
27 lines
689 B
TypeScript
import {exec} from '@actions/exec'
|
|
|
|
export async function fetchCommit(sha: string): Promise<void> {
|
|
const exitCode = await exec('git', ['fetch', '--depth=1', 'origin', sha])
|
|
if (exitCode !== 0) {
|
|
throw new Error(`Fetching commit ${sha} failed`)
|
|
}
|
|
}
|
|
|
|
export async function getChangedFiles(sha: string): Promise<string[]> {
|
|
let output = ''
|
|
const exitCode = await exec('git', ['diff-index', '--name-only', sha], {
|
|
listeners: {
|
|
stdout: (data: Buffer) => (output += data.toString())
|
|
}
|
|
})
|
|
|
|
if (exitCode !== 0) {
|
|
throw new Error(`Couldn't determine changed files`)
|
|
}
|
|
|
|
return output
|
|
.split('\n')
|
|
.map(s => s.trim())
|
|
.filter(s => s.length > 0)
|
|
}
|