Compare commits

...

5 Commits

Author SHA1 Message Date
Marcus Wirtz a6331e1c6b
Merge b23eb344e8 into 3d3c42e5aa 2026-07-18 17:41:15 -04:00
Aiqiao Yan 3d3c42e5aa
prep v7.0.1 release (#2531)
* prep v7.0.1 release

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-17 14:45:11 -04:00
Aiqiao Yan 28802689a1
escape values passed to --unset (#2530) 2026-07-17 13:44:40 -04:00
Marcus Wirtz b23eb344e8
Fix stuff 2026-04-21 12:30:04 +02:00
Marcus Wirtz a0eb51f8ea
fix: fix adding safe-directory in container 2026-04-21 11:32:17 +02:00
10 changed files with 68 additions and 34 deletions

View File

@ -314,7 +314,6 @@ jobs:
fi
# Verify auth token
git config --global --add safe.directory "*"
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
# needed to make checkout post cleanup succeed

View File

@ -1,5 +1,18 @@
# Changelog
## v7.0.1
* Bump github/codeql-action from 3 to 4 by @dependabot[bot] in https://github.com/actions/checkout/pull/2475
* Bump actions/setup-node from 4 to 6 by @dependabot[bot] in https://github.com/actions/checkout/pull/2477
* Bump docker/build-push-action from 6.5.0 to 7.2.0 by @dependabot[bot] in https://github.com/actions/checkout/pull/2478
* Bump docker/login-action from 3.3.0 to 4.2.0 by @dependabot[bot] in https://github.com/actions/checkout/pull/2479
* Bump actions/checkout from 6 to 7 by @dependabot[bot] in https://github.com/actions/checkout/pull/2488
* Bump actions/upload-artifact from 4 to 7 by @dependabot[bot] in https://github.com/actions/checkout/pull/2476
* eslint 9 by @dependabot[bot] in https://github.com/actions/checkout/pull/2474
* Bump the minor-actions-dependencies group with 2 updates by @dependabot[bot] in https://github.com/actions/checkout/pull/2499
* skip running unsafe pr check if input is default by @aiqiaoy in https://github.com/actions/checkout/pull/2518
* trim only ascii whitespace for branch by @aiqiaoy in https://github.com/actions/checkout/pull/2521
* escape values passed to --unset by @aiqiaoy in https://github.com/actions/checkout/pull/2530
## v7.0.0
* Block checking out fork PR for pull_request_target and workflow_run by @aiqiaoy in https://github.com/actions/checkout/pull/2454
* Bump actions/publish-immutable-action from 0.0.3 to 0.0.4 in the minor-actions-dependencies group across 1 directory by @dependabot[bot] in https://github.com/actions/checkout/pull/2458

View File

@ -15,9 +15,6 @@ fi
cd "$CHECKOUT_PATH"
# Add safe directory for container environments
git config --global --add safe.directory "*" 2>/dev/null || true
# Show the includeIf configuration
echo "Git config includeIf entries:"
git config --list --show-origin | grep -i include || true

2
dist/index.js vendored
View File

@ -35913,7 +35913,7 @@ class GitCommandManager {
else {
args.push(globalConfig ? '--global' : '--local');
}
args.push('--unset', configKey, configValue);
args.push('--unset', configKey, regexp_helper_escape(configValue));
const output = await this.execGit(args, true);
return output.exitCode === 0;
}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "checkout",
"version": "7.0.0",
"version": "7.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "checkout",
"version": "7.0.0",
"version": "7.0.1",
"license": "MIT",
"dependencies": {
"@actions/core": "^3.0.1",

View File

@ -1,6 +1,6 @@
{
"name": "checkout",
"version": "7.0.0",
"version": "7.0.1",
"description": "checkout action",
"type": "module",
"main": "lib/main.js",

View File

@ -510,7 +510,7 @@ class GitCommandManager {
} else {
args.push(globalConfig ? '--global' : '--local')
}
args.push('--unset', configKey, configValue)
args.push('--unset', configKey, regexpHelper.escape(configValue))
const output = await this.execGit(args, true)
return output.exitCode === 0

View File

@ -44,20 +44,14 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
if (git) {
authHelper = gitAuthHelper.createAuthHelper(git, settings)
if (settings.setSafeDirectory) {
// 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
// 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 addSafeDirectory(settings.repositoryPath, git, authHelper)
const containerPath = getContainerRepositoryPath(
settings.repositoryPath,
settings.githubWorkspacePath
)
await git
.config('safe.directory', settings.repositoryPath, true, true)
.catch(error => {
core.info(
`Failed to initialize safe directory with error: ${error}`
)
})
if (containerPath && containerPath !== settings.repositoryPath) {
await addSafeDirectory(containerPath, git, authHelper)
}
stateHelper.setSafeDirectory()
}
@ -350,18 +344,7 @@ export async function cleanup(repositoryPath: string): Promise<void> {
const authHelper = gitAuthHelper.createAuthHelper(git)
try {
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
// 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 addSafeDirectory(repositoryPath, git, authHelper)
}
await authHelper.removeAuth()
@ -390,3 +373,39 @@ async function getGitCommandManager(
return undefined
}
}
async function addSafeDirectory(
safeDirectory: string,
git: IGitCommandManager,
authHelper: gitAuthHelper.IGitAuthHelper
): Promise<void> {
await authHelper.configureTempGlobalConfig()
core.info(`Adding '${safeDirectory}' to the git global config as a safe directory`)
await git.config('safe.directory', safeDirectory, true, true).catch(error => {
core.info(`Failed to initialize safe directory with error: ${error}`)
})
}
function getContainerRepositoryPath(
repositoryPath: string,
githubWorkspace?: string
): string {
if (!githubWorkspace) {
return ''
}
let relativeRepositoryPath = path.relative(githubWorkspace, repositoryPath)
if (!relativeRepositoryPath || relativeRepositoryPath === '.') {
return '/github/workspace'
}
if (
relativeRepositoryPath.startsWith('..') ||
path.isAbsolute(relativeRepositoryPath)
) {
return ''
}
relativeRepositoryPath = relativeRepositoryPath.replace(/\\/g, '/')
return path.posix.join('/github/workspace', relativeRepositoryPath)
}

View File

@ -1,4 +1,9 @@
export interface IGitSourceSettings {
/**
* The workflow workspace path
*/
githubWorkspacePath?: string
/**
* The location on disk where the repository will be placed
*/

View File

@ -15,6 +15,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
throw new Error('GITHUB_WORKSPACE not defined')
}
githubWorkspacePath = path.resolve(githubWorkspacePath)
result.githubWorkspacePath = githubWorkspacePath
core.debug(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
fsHelper.directoryExistsSync(githubWorkspacePath, true)