Skip to content

Commit

Permalink
fix: error using current path to determine the .git dir location (#1299)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 24, 2023
1 parent d6d7cb2 commit e5efec4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
17 changes: 14 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit e5efec4

Please sign in to comment.