3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-16 19:27:39 +00:00

fix: error using current path to determine the .git dir location (#1299)

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com>
This commit is contained in:
Tonye Jack 2023-06-24 09:27:16 -06:00 committed by GitHub
parent d6d7cb291e
commit e5efec47f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View file

@ -552,6 +552,24 @@ export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
return stdout.trim()
}
export const isInsideWorkTree = async ({
cwd
}: {
cwd: string
}): Promise<boolean> => {
const {stdout} = await exec.getExecOutput(
'git',
['rev-parse', '--is-inside-work-tree'],
{
cwd,
ignoreReturnCode: true,
silent: !core.isDebug()
}
)
return stdout.trim() === 'true'
}
export const getRemoteBranchHeadSha = async ({
cwd,
branch
@ -1103,6 +1121,9 @@ export const hasLocalGitDirectory = async ({
}: {
workingDirectory: string
}): Promise<boolean> => {
const gitDirectory = path.join(workingDirectory, '.git')
return await exists(gitDirectory)
const insideWorkTree = await isInsideWorkTree({
cwd: workingDirectory
})
return insideWorkTree
}