mirror of
https://code.forgejo.org/actions/checkout.git
synced 2026-04-22 15:49:38 +00:00
Fix stuff
This commit is contained in:
parent
a0eb51f8ea
commit
b23eb344e8
1 changed files with 6 additions and 15 deletions
|
|
@ -44,13 +44,13 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
if (git) {
|
if (git) {
|
||||||
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
if (settings.setSafeDirectory) {
|
if (settings.setSafeDirectory) {
|
||||||
await addSafeDirectory(settings.repositoryPath, git)
|
await addSafeDirectory(settings.repositoryPath, git, authHelper)
|
||||||
const containerPath = getContainerRepositoryPath(
|
const containerPath = getContainerRepositoryPath(
|
||||||
settings.repositoryPath,
|
settings.repositoryPath,
|
||||||
settings.githubWorkspacePath
|
settings.githubWorkspacePath
|
||||||
)
|
)
|
||||||
if (containerPath && containerPath !== settings.repositoryPath) {
|
if (containerPath && containerPath !== settings.repositoryPath) {
|
||||||
await addSafeDirectory(containerPath, git)
|
await addSafeDirectory(containerPath, git, authHelper)
|
||||||
}
|
}
|
||||||
|
|
||||||
stateHelper.setSafeDirectory()
|
stateHelper.setSafeDirectory()
|
||||||
|
|
@ -327,18 +327,7 @@ export async function cleanup(repositoryPath: string): Promise<void> {
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git)
|
const authHelper = gitAuthHelper.createAuthHelper(git)
|
||||||
try {
|
try {
|
||||||
if (stateHelper.PostSetSafeDirectory) {
|
if (stateHelper.PostSetSafeDirectory) {
|
||||||
// Setup the repository path as a safe directory, so if we pass this into a container job with a different user it doesn't fail
|
await addSafeDirectory(repositoryPath, git, authHelper)
|
||||||
// Otherwise all git commands we run in a container fail
|
|
||||||
await authHelper.configureTempGlobalConfig()
|
|
||||||
core.info(
|
|
||||||
`Adding repository directory to the temporary git global config as a safe directory`
|
|
||||||
)
|
|
||||||
|
|
||||||
await git
|
|
||||||
.config('safe.directory', repositoryPath, true, true)
|
|
||||||
.catch(error => {
|
|
||||||
core.info(`Failed to initialize safe directory with error: ${error}`)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await authHelper.removeAuth()
|
await authHelper.removeAuth()
|
||||||
|
|
@ -370,8 +359,10 @@ async function getGitCommandManager(
|
||||||
|
|
||||||
async function addSafeDirectory(
|
async function addSafeDirectory(
|
||||||
safeDirectory: string,
|
safeDirectory: string,
|
||||||
git: IGitCommandManager
|
git: IGitCommandManager,
|
||||||
|
authHelper: gitAuthHelper.IGitAuthHelper
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
await authHelper.configureTempGlobalConfig()
|
||||||
core.info(`Adding '${safeDirectory}' to the git global config as a safe directory`)
|
core.info(`Adding '${safeDirectory}' to the git global config as a safe directory`)
|
||||||
await git.config('safe.directory', safeDirectory, true, true).catch(error => {
|
await git.config('safe.directory', safeDirectory, true, true).catch(error => {
|
||||||
core.info(`Failed to initialize safe directory with error: ${error}`)
|
core.info(`Failed to initialize safe directory with error: ${error}`)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue