mirror of
https://github.com/actions/checkout.git
synced 2026-05-13 16:38:07 +00:00
Compare commits
1 Commits
2afd9d1372
...
c400e00279
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c400e00279 |
@ -22,11 +22,6 @@ let settings: IGitSourceSettings
|
||||
let sshPath: 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', () => {
|
||||
beforeAll(async () => {
|
||||
// SSH
|
||||
@ -266,8 +261,7 @@ describe('git-auth-helper tests', () => {
|
||||
await fs.promises.symlink(workspace, symlinkPath)
|
||||
|
||||
// Make git appear to be operating from the symlink path
|
||||
const mockGetWorkingDirectory = git.getWorkingDirectory as jest.Mock
|
||||
mockGetWorkingDirectory.mockReturnValue(symlinkPath)
|
||||
;(git.getWorkingDirectory as jest.Mock).mockReturnValue(symlinkPath)
|
||||
process.env['GITHUB_WORKSPACE'] = symlinkPath
|
||||
|
||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||
@ -279,10 +273,10 @@ describe('git-auth-helper tests', () => {
|
||||
const localConfigContent = (
|
||||
await fs.promises.readFile(localGitConfigPath)
|
||||
).toString()
|
||||
const realGitDir = convertBackslashes(
|
||||
const realGitDir = (
|
||||
await fs.promises.realpath(path.join(symlinkPath, '.git'))
|
||||
)
|
||||
const symlinkGitDir = convertBackslashes(path.join(symlinkPath, '.git'))
|
||||
).replace(/\\/g, '/')
|
||||
const symlinkGitDir = path.join(symlinkPath, '.git').replace(/\\/g, '/')
|
||||
|
||||
expect(realGitDir).not.toBe(symlinkGitDir) // sanity check: paths differ
|
||||
expect(
|
||||
@ -301,11 +295,10 @@ describe('git-auth-helper tests', () => {
|
||||
// Arrange
|
||||
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()
|
||||
const nonexistentPath = path.join(runnerTemp, 'does-not-exist')
|
||||
const mockGetWorkingDirectory = git.getWorkingDirectory as jest.Mock
|
||||
mockGetWorkingDirectory.mockReturnValue(nonexistentPath)
|
||||
;(git.getWorkingDirectory as jest.Mock).mockReturnValue(nonexistentPath)
|
||||
|
||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||
|
||||
@ -316,9 +309,9 @@ describe('git-auth-helper tests', () => {
|
||||
const localConfigContent = (
|
||||
await fs.promises.readFile(localGitConfigPath)
|
||||
).toString()
|
||||
const fallbackGitDir = convertBackslashes(
|
||||
path.join(nonexistentPath, '.git')
|
||||
)
|
||||
const fallbackGitDir = path
|
||||
.join(nonexistentPath, '.git')
|
||||
.replace(/\\/g, '/')
|
||||
expect(
|
||||
localConfigContent.indexOf(`includeIf.gitdir:${fallbackGitDir}.path`)
|
||||
).toBeGreaterThanOrEqual(0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user