mirror of
https://github.com/actions/checkout.git
synced 2026-05-14 00:58:06 +00:00
Compare commits
No commits in common. "fbeb4a8af3195f75673a80e060f5102e92d36ecf" and "8461cead75cdaf1a808b112c862f982ff023ed40" have entirely different histories.
fbeb4a8af3
...
8461cead75
@ -22,11 +22,6 @@ let settings: IGitSourceSettings
|
|||||||
let sshPath: string
|
let sshPath: string
|
||||||
let githubServerUrl: string
|
let githubServerUrl: string
|
||||||
|
|
||||||
// Helper function to normalize path separators to forward slashes
|
|
||||||
function convertBackslashes(file: string): string {
|
|
||||||
return file.replace(/\\/g, '/')
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('git-auth-helper tests', () => {
|
describe('git-auth-helper tests', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// SSH
|
// SSH
|
||||||
@ -266,8 +261,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
await fs.promises.symlink(workspace, symlinkPath)
|
await fs.promises.symlink(workspace, symlinkPath)
|
||||||
|
|
||||||
// Make git appear to be operating from the symlink path
|
// Make git appear to be operating from the symlink path
|
||||||
const mockGetWorkingDirectory = git.getWorkingDirectory as jest.Mock
|
;(git.getWorkingDirectory as jest.Mock).mockReturnValue(symlinkPath)
|
||||||
mockGetWorkingDirectory.mockReturnValue(symlinkPath)
|
|
||||||
process.env['GITHUB_WORKSPACE'] = symlinkPath
|
process.env['GITHUB_WORKSPACE'] = symlinkPath
|
||||||
|
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
@ -279,10 +273,10 @@ describe('git-auth-helper tests', () => {
|
|||||||
const localConfigContent = (
|
const localConfigContent = (
|
||||||
await fs.promises.readFile(localGitConfigPath)
|
await fs.promises.readFile(localGitConfigPath)
|
||||||
).toString()
|
).toString()
|
||||||
const realGitDir = convertBackslashes(
|
const realGitDir = (
|
||||||
await fs.promises.realpath(path.join(symlinkPath, '.git'))
|
await fs.promises.realpath(path.join(symlinkPath, '.git'))
|
||||||
)
|
).replace(/\\/g, '/')
|
||||||
const symlinkGitDir = convertBackslashes(path.join(symlinkPath, '.git'))
|
const symlinkGitDir = path.join(symlinkPath, '.git').replace(/\\/g, '/')
|
||||||
|
|
||||||
expect(realGitDir).not.toBe(symlinkGitDir) // sanity check: paths differ
|
expect(realGitDir).not.toBe(symlinkGitDir) // sanity check: paths differ
|
||||||
expect(
|
expect(
|
||||||
@ -301,11 +295,10 @@ describe('git-auth-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(configureAuth_fallsBackWhenRealpathSyncFails)
|
await setup(configureAuth_fallsBackWhenRealpathSyncFails)
|
||||||
|
|
||||||
// Use a nonexistent path so realpathSync throws ENOENT naturally,
|
// Use a non-existent path so realpathSync throws ENOENT naturally,
|
||||||
// exercising the catch fallback in configureToken()
|
// exercising the catch fallback in configureToken()
|
||||||
const nonexistentPath = path.join(runnerTemp, 'does-not-exist')
|
const nonexistentPath = path.join(runnerTemp, 'does-not-exist')
|
||||||
const mockGetWorkingDirectory = git.getWorkingDirectory as jest.Mock
|
;(git.getWorkingDirectory as jest.Mock).mockReturnValue(nonexistentPath)
|
||||||
mockGetWorkingDirectory.mockReturnValue(nonexistentPath)
|
|
||||||
|
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
|
|
||||||
@ -316,9 +309,9 @@ describe('git-auth-helper tests', () => {
|
|||||||
const localConfigContent = (
|
const localConfigContent = (
|
||||||
await fs.promises.readFile(localGitConfigPath)
|
await fs.promises.readFile(localGitConfigPath)
|
||||||
).toString()
|
).toString()
|
||||||
const fallbackGitDir = convertBackslashes(
|
const fallbackGitDir = path
|
||||||
path.join(nonexistentPath, '.git')
|
.join(nonexistentPath, '.git')
|
||||||
)
|
.replace(/\\/g, '/')
|
||||||
expect(
|
expect(
|
||||||
localConfigContent.indexOf(`includeIf.gitdir:${fallbackGitDir}.path`)
|
localConfigContent.indexOf(`includeIf.gitdir:${fallbackGitDir}.path`)
|
||||||
).toBeGreaterThanOrEqual(0)
|
).toBeGreaterThanOrEqual(0)
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import * as path from 'path'
|
|||||||
import * as regexpHelper from './regexp-helper'
|
import * as regexpHelper from './regexp-helper'
|
||||||
import * as stateHelper from './state-helper'
|
import * as stateHelper from './state-helper'
|
||||||
import * as urlHelper from './url-helper'
|
import * as urlHelper from './url-helper'
|
||||||
import {v4 as uuid} from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
import {IGitCommandManager} from './git-command-manager'
|
import { IGitCommandManager } from './git-command-manager'
|
||||||
import {IGitSourceSettings} from './git-source-settings'
|
import { IGitSourceSettings } from './git-source-settings'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
const SSH_COMMAND_KEY = 'core.sshCommand'
|
const SSH_COMMAND_KEY = 'core.sshCommand'
|
||||||
@ -92,7 +92,7 @@ class GitAuthHelper {
|
|||||||
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
||||||
const uniqueId = uuid()
|
const uniqueId = uuid()
|
||||||
this.temporaryHomePath = path.join(runnerTemp, uniqueId)
|
this.temporaryHomePath = path.join(runnerTemp, uniqueId)
|
||||||
await fs.promises.mkdir(this.temporaryHomePath, {recursive: true})
|
await fs.promises.mkdir(this.temporaryHomePath, { recursive: true })
|
||||||
|
|
||||||
// Copy the global git config
|
// Copy the global git config
|
||||||
const gitConfigPath = path.join(
|
const gitConfigPath = path.join(
|
||||||
@ -258,11 +258,11 @@ class GitAuthHelper {
|
|||||||
const uniqueId = uuid()
|
const uniqueId = uuid()
|
||||||
this.sshKeyPath = path.join(runnerTemp, uniqueId)
|
this.sshKeyPath = path.join(runnerTemp, uniqueId)
|
||||||
stateHelper.setSshKeyPath(this.sshKeyPath)
|
stateHelper.setSshKeyPath(this.sshKeyPath)
|
||||||
await fs.promises.mkdir(runnerTemp, {recursive: true})
|
await fs.promises.mkdir(runnerTemp, { recursive: true })
|
||||||
await fs.promises.writeFile(
|
await fs.promises.writeFile(
|
||||||
this.sshKeyPath,
|
this.sshKeyPath,
|
||||||
this.settings.sshKey.trim() + '\n',
|
this.settings.sshKey.trim() + '\n',
|
||||||
{mode: 0o600}
|
{ mode: 0o600 }
|
||||||
)
|
)
|
||||||
|
|
||||||
// Remove inherited permissions on Windows
|
// Remove inherited permissions on Windows
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user