Skip to content

Commit

Permalink
fix: error using current path to determine the .git dir location
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Jun 24, 2023
1 parent d6d7cb2 commit 6cf165d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,16 @@ export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
return stdout.trim()
}

export const getGitDir = async ({cwd}: {cwd: string}): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', '--git-dir'], {
cwd,
ignoreReturnCode: true,
silent: !core.isDebug()
})

return stdout.trim()
}

export const getRemoteBranchHeadSha = async ({
cwd,
branch
Expand Down Expand Up @@ -1103,6 +1113,13 @@ export const hasLocalGitDirectory = async ({
}: {
workingDirectory: string
}): Promise<boolean> => {
const gitDirectory = path.join(workingDirectory, '.git')
return await exists(gitDirectory)
const gitDirectory = await getGitDir({
cwd: workingDirectory
})

if (gitDirectory) {
return await exists(gitDirectory)
}

return false
}

0 comments on commit 6cf165d

Please sign in to comment.