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:
parent
d6d7cb291e
commit
e5efec47f6
3 changed files with 23 additions and 2 deletions
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
25
src/utils.ts
25
src/utils.ts
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue