feat: switch to use name status (#1230)
Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
180
src/main.ts
180
src/main.ts
@@ -1,15 +1,22 @@
|
||||
import * as core from '@actions/core'
|
||||
import path from 'path'
|
||||
import {getDiffFiles, getRenamedFiles} from './changedFiles'
|
||||
import {
|
||||
getAllChangeTypeFiles,
|
||||
getAllDiffFiles,
|
||||
getChangeTypeFiles,
|
||||
getRenamedFiles,
|
||||
ChangeTypeEnum
|
||||
} from './changedFiles'
|
||||
import {
|
||||
DiffResult,
|
||||
getSHAForPullRequestEvent,
|
||||
getSHAForPushEvent,
|
||||
DiffResult
|
||||
getSHAForPushEvent
|
||||
} from './commitSha'
|
||||
import {getEnv} from './env'
|
||||
import {getInputs} from './inputs'
|
||||
import {
|
||||
getFilePatterns,
|
||||
getFilteredChangedFiles,
|
||||
getSubmodulePath,
|
||||
isRepoShallow,
|
||||
setOutput,
|
||||
@@ -105,16 +112,27 @@ export async function run(): Promise<void> {
|
||||
inputs,
|
||||
workingDirectory
|
||||
})
|
||||
core.debug(`File patterns: ${filePatterns}`)
|
||||
|
||||
const addedFiles = await getDiffFiles({
|
||||
inputs,
|
||||
const allDiffFiles = await getAllDiffFiles({
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'A',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
})
|
||||
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
||||
|
||||
const allFilteredDiffFiles = await getFilteredChangedFiles({
|
||||
allDiffFiles,
|
||||
filePatterns
|
||||
})
|
||||
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
||||
|
||||
const addedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Added]
|
||||
})
|
||||
core.debug(`Added files: ${addedFiles}`)
|
||||
await setOutput({
|
||||
key: 'added_files',
|
||||
@@ -122,14 +140,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const copiedFiles = await getDiffFiles({
|
||||
const copiedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'C',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Copied]
|
||||
})
|
||||
core.debug(`Copied files: ${copiedFiles}`)
|
||||
await setOutput({
|
||||
@@ -138,14 +152,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const modifiedFiles = await getDiffFiles({
|
||||
const modifiedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'M',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Modified]
|
||||
})
|
||||
core.debug(`Modified files: ${modifiedFiles}`)
|
||||
await setOutput({
|
||||
@@ -154,14 +164,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const renamedFiles = await getDiffFiles({
|
||||
const renamedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'R',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Renamed]
|
||||
})
|
||||
core.debug(`Renamed files: ${renamedFiles}`)
|
||||
await setOutput({
|
||||
@@ -170,14 +176,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const typeChangedFiles = await getDiffFiles({
|
||||
const typeChangedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'T',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.TypeChanged]
|
||||
})
|
||||
core.debug(`Type changed files: ${typeChangedFiles}`)
|
||||
await setOutput({
|
||||
@@ -186,14 +188,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const unmergedFiles = await getDiffFiles({
|
||||
const unmergedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'U',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Unmerged]
|
||||
})
|
||||
core.debug(`Unmerged files: ${unmergedFiles}`)
|
||||
await setOutput({
|
||||
@@ -202,14 +200,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const unknownFiles = await getDiffFiles({
|
||||
const unknownFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'X',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Unknown]
|
||||
})
|
||||
core.debug(`Unknown files: ${unknownFiles}`)
|
||||
await setOutput({
|
||||
@@ -218,14 +212,9 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const allChangedAndModifiedFiles = await getDiffFiles({
|
||||
const allChangedAndModifiedFiles = await getAllChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'ACDMRTUX',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles
|
||||
})
|
||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
||||
await setOutput({
|
||||
@@ -234,14 +223,15 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const allChangedFiles = await getDiffFiles({
|
||||
const allChangedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'ACMR',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [
|
||||
ChangeTypeEnum.Added,
|
||||
ChangeTypeEnum.Copied,
|
||||
ChangeTypeEnum.Modified,
|
||||
ChangeTypeEnum.Renamed
|
||||
]
|
||||
})
|
||||
core.debug(`All changed files: ${allChangedFiles}`)
|
||||
await setOutput({
|
||||
@@ -256,13 +246,15 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const allOtherChangedFiles = await getDiffFiles({
|
||||
const allOtherChangedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'ACMR',
|
||||
submodulePaths
|
||||
changedFiles: allDiffFiles,
|
||||
changeTypes: [
|
||||
ChangeTypeEnum.Added,
|
||||
ChangeTypeEnum.Copied,
|
||||
ChangeTypeEnum.Modified,
|
||||
ChangeTypeEnum.Renamed
|
||||
]
|
||||
})
|
||||
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
||||
|
||||
@@ -289,14 +281,16 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const allModifiedFiles = await getDiffFiles({
|
||||
const allModifiedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'ACMRD',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [
|
||||
ChangeTypeEnum.Added,
|
||||
ChangeTypeEnum.Copied,
|
||||
ChangeTypeEnum.Modified,
|
||||
ChangeTypeEnum.Renamed,
|
||||
ChangeTypeEnum.Deleted
|
||||
]
|
||||
})
|
||||
core.debug(`All modified files: ${allModifiedFiles}`)
|
||||
await setOutput({
|
||||
@@ -311,13 +305,16 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const allOtherModifiedFiles = await getDiffFiles({
|
||||
const allOtherModifiedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'ACMRD',
|
||||
submodulePaths
|
||||
changedFiles: allDiffFiles,
|
||||
changeTypes: [
|
||||
ChangeTypeEnum.Added,
|
||||
ChangeTypeEnum.Copied,
|
||||
ChangeTypeEnum.Modified,
|
||||
ChangeTypeEnum.Renamed,
|
||||
ChangeTypeEnum.Deleted
|
||||
]
|
||||
})
|
||||
|
||||
const otherModifiedFiles = allOtherModifiedFiles
|
||||
@@ -343,14 +340,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const deletedFiles = await getDiffFiles({
|
||||
const deletedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'D',
|
||||
filePatterns,
|
||||
submodulePaths
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Deleted]
|
||||
})
|
||||
core.debug(`Deleted files: ${deletedFiles}`)
|
||||
await setOutput({
|
||||
@@ -365,13 +358,10 @@ export async function run(): Promise<void> {
|
||||
inputs
|
||||
})
|
||||
|
||||
const allOtherDeletedFiles = await getDiffFiles({
|
||||
const allOtherDeletedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
hasSubmodule,
|
||||
diffResult,
|
||||
diffFilter: 'D',
|
||||
submodulePaths
|
||||
changedFiles: allDiffFiles,
|
||||
changeTypes: [ChangeTypeEnum.Deleted]
|
||||
})
|
||||
|
||||
const otherDeletedFiles = allOtherDeletedFiles
|
||||
|
||||
Reference in New Issue
Block a user