feat: add support for restricting the deleted files output to only deleted directories

This commit is contained in:
Tonye Jack
2023-09-21 20:47:12 -06:00
parent 0b947ed818
commit e6ce728d79
5 changed files with 71 additions and 8 deletions

View File

@@ -139,7 +139,7 @@ export const verifyMinimumGitVersion = async (): Promise<void> => {
* @param filePath - path to check
* @returns path exists
*/
const exists = async (filePath: string): Promise<boolean> => {
export const exists = async (filePath: string): Promise<boolean> => {
try {
await fs.access(filePath)
return true
@@ -233,6 +233,36 @@ export const updateGitGlobalConfig = async ({
}
}
/**
* Get tracked git directories
* @param cwd - working directory
*/
export const getGitTrackedDirectories = async ({
cwd
}: {
cwd: string
}): Promise<string[]> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git',
['ls-tree', '-d', '-r', '--name-only', 'HEAD'],
{
cwd,
ignoreReturnCode: true,
silent: !core.isDebug()
}
)
if (exitCode !== 0) {
core.warning(stderr || "Couldn't list tracked directories")
return []
}
return stdout
.trim()
.split('\n')
.map((line: string) => normalizeSeparators(line.trim()))
}
/**
* Checks if a git repository is shallow
* @param cwd - working directory