feat: enhance error handling for non-git directories (#1885)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack
2024-01-25 11:46:48 -07:00
committed by GitHub
parent 2cb2c9234e
commit 90a06d6ba9
5 changed files with 45 additions and 5 deletions

View File

@@ -264,9 +264,8 @@ export async function run(): Promise<void> {
})
} else {
if (!hasGitDirectory) {
core.info(`Running on a ${github.context.eventName} event...`)
throw new Error(
`Can't find local .git in ${workingDirectory} directory. Please run actions/checkout before this action (Make sure the 'path' input is correct). If you intend to use Github's REST API note that only pull_request* events are supported.`
`Unable to locate the git repository in the given path: ${workingDirectory}.\n Please run actions/checkout before this action (Make sure the 'path' input is correct).\n If you intend to use Github's REST API note that only pull_request* events are supported. Current event is "${github.context.eventName}".`
)
}

View File

@@ -680,6 +680,12 @@ export const isInsideWorkTree = async ({
}
)
if (stdout.trim() !== 'true') {
core.debug(
`The current working directory is not inside a git repository: ${cwd}`
)
}
return stdout.trim() === 'true'
}