mirror of
https://gitea.com/actions/dorny-paths-filter.git
synced 2025-12-16 05:17:18 +00:00
Support push event (#10)
* Support triggering from push event * Add self-test to build workflow * Update action metadata
This commit is contained in:
12
src/git.ts
12
src/git.ts
@@ -1,22 +1,22 @@
|
||||
import {exec} from '@actions/exec'
|
||||
|
||||
export async function fetchBranch(base: string): Promise<void> {
|
||||
const exitCode = await exec('git', ['fetch', '--depth=1', 'origin', base])
|
||||
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 branch ${base} failed, exiting`)
|
||||
throw new Error(`Fetching commit ${sha} failed`)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getChangedFiles(base: string): Promise<string[]> {
|
||||
export async function getChangedFiles(sha: string): Promise<string[]> {
|
||||
let output = ''
|
||||
const exitCode = await exec('git', ['diff-index', '--name-only', base], {
|
||||
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, exiting`)
|
||||
throw new Error(`Couldn't determine changed files`)
|
||||
}
|
||||
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user