mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-05 19:35:54 +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()
|
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 ({
|
export const getRemoteBranchHeadSha = async ({
|
||||||
cwd,
|
cwd,
|
||||||
branch
|
branch
|
||||||
|
@ -1103,6 +1121,9 @@ export const hasLocalGitDirectory = async ({
|
||||||
}: {
|
}: {
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
}): Promise<boolean> => {
|
}): Promise<boolean> => {
|
||||||
const gitDirectory = path.join(workingDirectory, '.git')
|
const insideWorkTree = await isInsideWorkTree({
|
||||||
return await exists(gitDirectory)
|
cwd: workingDirectory
|
||||||
|
})
|
||||||
|
|
||||||
|
return insideWorkTree
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue