mirror of
https://github.com/actions/checkout.git
synced 2026-07-06 04:30:09 +00:00
Compare commits
No commits in common. "f0282184c7ce73ab54c7e4ab5a617122602e575f" and "0f9f3aa320cb53abeb534aeb54048075d9697a0e" have entirely different histories.
f0282184c7
...
0f9f3aa320
@ -11,5 +11,4 @@ allowed:
|
|||||||
- unlicense
|
- unlicense
|
||||||
|
|
||||||
reviewed:
|
reviewed:
|
||||||
npm:
|
npm:
|
||||||
- "@actions/http-client" # MIT
|
|
||||||
BIN
.licenses/npm/@actions/core.dep.yml
generated
BIN
.licenses/npm/@actions/core.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/exec.dep.yml
generated
BIN
.licenses/npm/@actions/exec.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/github.dep.yml
generated
BIN
.licenses/npm/@actions/github.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-4.0.1.dep.yml
generated
BIN
.licenses/npm/@actions/http-client-4.0.1.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/io.dep.yml
generated
BIN
.licenses/npm/@actions/io.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/auth-token.dep.yml
generated
BIN
.licenses/npm/@octokit/auth-token.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/core.dep.yml
generated
BIN
.licenses/npm/@octokit/core.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/openapi-types-22.1.0.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/openapi-types-22.1.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/plugin-paginate-rest.dep.yml
generated
BIN
.licenses/npm/@octokit/plugin-paginate-rest.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/request-error.dep.yml
generated
BIN
.licenses/npm/@octokit/request-error.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/request.dep.yml
generated
BIN
.licenses/npm/@octokit/request.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/types-13.4.1.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/types-13.4.1.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/before-after-hook.dep.yml
generated
BIN
.licenses/npm/before-after-hook.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/content-type.dep.yml
generated
BIN
.licenses/npm/content-type.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/deprecation.dep.yml
generated
Normal file
BIN
.licenses/npm/deprecation.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/once.dep.yml
generated
Normal file
BIN
.licenses/npm/once.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/semver.dep.yml
generated
BIN
.licenses/npm/semver.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
BIN
.licenses/npm/undici.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/universal-user-agent.dep.yml
generated
BIN
.licenses/npm/universal-user-agent.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/uuid-8.3.2.dep.yml
generated
Normal file
BIN
.licenses/npm/uuid-8.3.2.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/uuid-9.0.1.dep.yml
generated
Normal file
BIN
.licenses/npm/uuid-9.0.1.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/wrappy.dep.yml
generated
Normal file
BIN
.licenses/npm/wrappy.dep.yml
generated
Normal file
Binary file not shown.
@ -1,46 +1,12 @@
|
|||||||
import {
|
import * as core from '@actions/core'
|
||||||
jest,
|
|
||||||
describe,
|
|
||||||
it,
|
|
||||||
expect,
|
|
||||||
beforeAll,
|
|
||||||
beforeEach,
|
|
||||||
afterEach,
|
|
||||||
afterAll
|
|
||||||
} from '@jest/globals'
|
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
import * as gitAuthHelper from '../lib/git-auth-helper'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {fileURLToPath} from 'url'
|
import * as stateHelper from '../lib/state-helper'
|
||||||
|
import {IGitCommandManager} from '../lib/git-command-manager'
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
import {IGitSourceSettings} from '../lib/git-source-settings'
|
||||||
|
|
||||||
// Mock @actions/core before loading git-auth-helper
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
setSecret: jest.fn(),
|
|
||||||
error: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
info: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
setFailed: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock state-helper
|
|
||||||
jest.unstable_mockModule('../src/state-helper.js', () => ({
|
|
||||||
setSshKeyPath: jest.fn(),
|
|
||||||
setSshKnownHostsPath: jest.fn(),
|
|
||||||
IsPost: false,
|
|
||||||
RepositoryPath: ''
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const core = await import('@actions/core')
|
|
||||||
const gitAuthHelper = await import('../src/git-auth-helper.js')
|
|
||||||
type IGitCommandManager =
|
|
||||||
import('../src/git-command-manager.js').IGitCommandManager
|
|
||||||
type IGitSourceSettings =
|
|
||||||
import('../src/git-source-settings.js').IGitSourceSettings
|
|
||||||
|
|
||||||
const isWindows = process.platform === 'win32'
|
const isWindows = process.platform === 'win32'
|
||||||
const testWorkspace = path.join(__dirname, '_temp', 'git-auth-helper')
|
const testWorkspace = path.join(__dirname, '_temp', 'git-auth-helper')
|
||||||
@ -66,12 +32,25 @@ describe('git-auth-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks()
|
// Mock setSecret
|
||||||
|
jest.spyOn(core, 'setSecret').mockImplementation((secret: string) => {})
|
||||||
|
|
||||||
|
// Mock error/warning/info/debug
|
||||||
|
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
|
|
||||||
|
// Mock state helper
|
||||||
|
jest.spyOn(stateHelper, 'setSshKeyPath').mockImplementation(jest.fn())
|
||||||
|
jest
|
||||||
|
.spyOn(stateHelper, 'setSshKnownHostsPath')
|
||||||
|
.mockImplementation(jest.fn())
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// Unregister mocks
|
// Unregister mocks
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
|
|
||||||
// Restore HOME
|
// Restore HOME
|
||||||
if (originalHome) {
|
if (originalHome) {
|
||||||
@ -250,7 +229,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
await authHelper.configureAuth()
|
await authHelper.configureAuth()
|
||||||
|
|
||||||
// Assert secret
|
// Assert secret
|
||||||
const setSecretSpy = core.setSecret as jest.Mock<any>
|
const setSecretSpy = core.setSecret as jest.Mock<any, any>
|
||||||
expect(setSecretSpy).toHaveBeenCalledTimes(1)
|
expect(setSecretSpy).toHaveBeenCalledTimes(1)
|
||||||
const expectedSecret = Buffer.from(
|
const expectedSecret = Buffer.from(
|
||||||
`x-access-token:${settings.authToken}`,
|
`x-access-token:${settings.authToken}`,
|
||||||
@ -550,7 +529,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
settings.sshKey = ''
|
settings.sshKey = ''
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
await authHelper.configureAuth()
|
await authHelper.configureAuth()
|
||||||
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any>
|
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
|
||||||
mockSubmoduleForeach.mockClear() // reset calls
|
mockSubmoduleForeach.mockClear() // reset calls
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -583,7 +562,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
settings.persistCredentials = false
|
settings.persistCredentials = false
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
await authHelper.configureAuth()
|
await authHelper.configureAuth()
|
||||||
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any>
|
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
|
||||||
mockSubmoduleForeach.mockClear() // reset calls
|
mockSubmoduleForeach.mockClear() // reset calls
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -609,7 +588,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
settings.sshKey = ''
|
settings.sshKey = ''
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
await authHelper.configureAuth()
|
await authHelper.configureAuth()
|
||||||
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any>
|
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
|
||||||
mockSubmoduleForeach.mockClear() // reset calls
|
mockSubmoduleForeach.mockClear() // reset calls
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -648,7 +627,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
)
|
)
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
await authHelper.configureAuth()
|
await authHelper.configureAuth()
|
||||||
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any>
|
const mockSubmoduleForeach = git.submoduleForeach as jest.Mock<any, any>
|
||||||
mockSubmoduleForeach.mockClear() // reset calls
|
mockSubmoduleForeach.mockClear() // reset calls
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -830,7 +809,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
|
|
||||||
// Mock getSubmoduleConfigPaths to return our fake submodules (for both configure and remove)
|
// Mock getSubmoduleConfigPaths to return our fake submodules (for both configure and remove)
|
||||||
const mockGetSubmoduleConfigPaths =
|
const mockGetSubmoduleConfigPaths =
|
||||||
git.getSubmoduleConfigPaths as jest.Mock<any>
|
git.getSubmoduleConfigPaths as jest.Mock<any, any>
|
||||||
mockGetSubmoduleConfigPaths.mockResolvedValue([
|
mockGetSubmoduleConfigPaths.mockResolvedValue([
|
||||||
submodule1ConfigPath,
|
submodule1ConfigPath,
|
||||||
submodule2ConfigPath
|
submodule2ConfigPath
|
||||||
@ -1168,7 +1147,7 @@ async function setup(testName: string): Promise<void> {
|
|||||||
),
|
),
|
||||||
tryReset: jest.fn(),
|
tryReset: jest.fn(),
|
||||||
version: jest.fn()
|
version: jest.fn()
|
||||||
} as unknown as IGitCommandManager & {env: {[key: string]: string}}
|
}
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
authToken: 'some auth token',
|
authToken: 'some auth token',
|
||||||
|
|||||||
@ -1,51 +1,26 @@
|
|||||||
import {
|
import * as exec from '@actions/exec'
|
||||||
jest,
|
import * as fshelper from '../lib/fs-helper'
|
||||||
describe,
|
import * as commandManager from '../lib/git-command-manager'
|
||||||
it,
|
|
||||||
expect,
|
|
||||||
beforeAll,
|
|
||||||
beforeEach,
|
|
||||||
afterEach,
|
|
||||||
afterAll
|
|
||||||
} from '@jest/globals'
|
|
||||||
|
|
||||||
// Mock @actions/exec
|
let git: commandManager.IGitCommandManager
|
||||||
const mockExec = jest.fn()
|
let mockExec = jest.fn()
|
||||||
jest.unstable_mockModule('@actions/exec', () => ({
|
|
||||||
exec: mockExec
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock fs-helper
|
|
||||||
const mockFileExistsSync = jest.fn()
|
|
||||||
const mockDirectoryExistsSync = jest.fn()
|
|
||||||
jest.unstable_mockModule('../src/fs-helper.js', () => ({
|
|
||||||
fileExistsSync: mockFileExistsSync,
|
|
||||||
directoryExistsSync: mockDirectoryExistsSync
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const commandManager = await import('../src/git-command-manager.js')
|
|
||||||
type IGitCommandManager =
|
|
||||||
import('../src/git-command-manager.js').IGitCommandManager
|
|
||||||
|
|
||||||
let git: IGitCommandManager
|
|
||||||
|
|
||||||
describe('git-auth-helper tests', () => {
|
describe('git-auth-helper tests', () => {
|
||||||
beforeAll(async () => {})
|
beforeAll(async () => {})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockFileExistsSync.mockReset()
|
jest.spyOn(fshelper, 'fileExistsSync').mockImplementation(jest.fn())
|
||||||
mockDirectoryExistsSync.mockReset()
|
jest.spyOn(fshelper, 'directoryExistsSync').mockImplementation(jest.fn())
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(() => {})
|
afterAll(() => {})
|
||||||
|
|
||||||
it('branch list matches', async () => {
|
it('branch list matches', async () => {
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
console.log(args, options.listeners.stdout)
|
console.log(args, options.listeners.stdout)
|
||||||
|
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
@ -61,7 +36,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
const doSparseCheckout = false
|
const doSparseCheckout = false
|
||||||
@ -78,7 +53,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('ambiguous ref name output is captured', async () => {
|
it('ambiguous ref name output is captured', async () => {
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
console.log(args, options.listeners.stdout)
|
console.log(args, options.listeners.stdout)
|
||||||
|
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
@ -97,7 +72,7 @@ describe('git-auth-helper tests', () => {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
const doSparseCheckout = false
|
const doSparseCheckout = false
|
||||||
@ -116,9 +91,9 @@ describe('git-auth-helper tests', () => {
|
|||||||
|
|
||||||
describe('Test fetchDepth and fetchTags options', () => {
|
describe('Test fetchDepth and fetchTags options', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockFileExistsSync.mockReset()
|
jest.spyOn(fshelper, 'fileExistsSync').mockImplementation(jest.fn())
|
||||||
mockDirectoryExistsSync.mockReset()
|
jest.spyOn(fshelper, 'directoryExistsSync').mockImplementation(jest.fn())
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
console.log(args, options.listeners.stdout)
|
console.log(args, options.listeners.stdout)
|
||||||
|
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
@ -130,11 +105,11 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when fetchDepth is 0', async () => {
|
it('should call execGit with the correct arguments when fetchDepth is 0', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
const doSparseCheckout = false
|
const doSparseCheckout = false
|
||||||
@ -171,7 +146,7 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when fetchDepth is 0 and refSpec includes tags', async () => {
|
it('should call execGit with the correct arguments when fetchDepth is 0 and refSpec includes tags', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -209,7 +184,7 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when fetchDepth is 1', async () => {
|
it('should call execGit with the correct arguments when fetchDepth is 1', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -247,7 +222,7 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when fetchDepth is 1 and refSpec includes tags', async () => {
|
it('should call execGit with the correct arguments when fetchDepth is 1 and refSpec includes tags', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -286,7 +261,7 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when showProgress is true', async () => {
|
it('should call execGit with the correct arguments when showProgress is true', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -324,7 +299,7 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when fetchDepth is 42 and showProgress is true', async () => {
|
it('should call execGit with the correct arguments when fetchDepth is 42 and showProgress is true', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -364,7 +339,7 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should call execGit with the correct arguments when showProgress is true and refSpec includes tags', async () => {
|
it('should call execGit with the correct arguments when showProgress is true and refSpec includes tags', async () => {
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -405,23 +380,23 @@ describe('Test fetchDepth and fetchTags options', () => {
|
|||||||
|
|
||||||
describe('repository initialization object format', () => {
|
describe('repository initialization object format', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockFileExistsSync.mockReset()
|
jest.spyOn(fshelper, 'fileExistsSync').mockImplementation(jest.fn())
|
||||||
mockDirectoryExistsSync.mockReset()
|
jest.spyOn(fshelper, 'directoryExistsSync').mockImplementation(jest.fn())
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('initializes SHA-256 repositories with the matching object format', async () => {
|
it('initializes SHA-256 repositories with the matching object format', async () => {
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
options.listeners.stdout(Buffer.from('git version 2.50.1'))
|
options.listeners.stdout(Buffer.from('git version 2.50.1'))
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
git = await commandManager.createCommandManager('test', false, false)
|
git = await commandManager.createCommandManager('test', false, false)
|
||||||
|
|
||||||
@ -435,14 +410,14 @@ describe('repository initialization object format', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('initializes SHA-1 repositories with existing default arguments', async () => {
|
it('initializes SHA-1 repositories with existing default arguments', async () => {
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
options.listeners.stdout(Buffer.from('git version 2.50.1'))
|
options.listeners.stdout(Buffer.from('git version 2.50.1'))
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
git = await commandManager.createCommandManager('test', false, false)
|
git = await commandManager.createCommandManager('test', false, false)
|
||||||
|
|
||||||
@ -458,12 +433,12 @@ describe('repository initialization object format', () => {
|
|||||||
|
|
||||||
describe('git user-agent with orchestration ID', () => {
|
describe('git user-agent with orchestration ID', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockFileExistsSync.mockReset()
|
jest.spyOn(fshelper, 'fileExistsSync').mockImplementation(jest.fn())
|
||||||
mockDirectoryExistsSync.mockReset()
|
jest.spyOn(fshelper, 'directoryExistsSync').mockImplementation(jest.fn())
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
// Clean up environment variable to prevent test pollution
|
// Clean up environment variable to prevent test pollution
|
||||||
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
||||||
})
|
})
|
||||||
@ -473,7 +448,7 @@ describe('git user-agent with orchestration ID', () => {
|
|||||||
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
|
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
|
||||||
|
|
||||||
let capturedEnv: any = null
|
let capturedEnv: any = null
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
options.listeners.stdout(Buffer.from('2.18'))
|
options.listeners.stdout(Buffer.from('2.18'))
|
||||||
}
|
}
|
||||||
@ -481,7 +456,7 @@ describe('git user-agent with orchestration ID', () => {
|
|||||||
capturedEnv = options.env
|
capturedEnv = options.env
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -508,7 +483,7 @@ describe('git user-agent with orchestration ID', () => {
|
|||||||
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
|
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
|
||||||
|
|
||||||
let capturedEnv: any = null
|
let capturedEnv: any = null
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
options.listeners.stdout(Buffer.from('2.18'))
|
options.listeners.stdout(Buffer.from('2.18'))
|
||||||
}
|
}
|
||||||
@ -516,7 +491,7 @@ describe('git user-agent with orchestration ID', () => {
|
|||||||
capturedEnv = options.env
|
capturedEnv = options.env
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
@ -542,7 +517,7 @@ describe('git user-agent with orchestration ID', () => {
|
|||||||
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
||||||
|
|
||||||
let capturedEnv: any = null
|
let capturedEnv: any = null
|
||||||
mockExec.mockImplementation((path: any, args: any, options: any) => {
|
mockExec.mockImplementation((path, args, options) => {
|
||||||
if (args.includes('version')) {
|
if (args.includes('version')) {
|
||||||
options.listeners.stdout(Buffer.from('2.18'))
|
options.listeners.stdout(Buffer.from('2.18'))
|
||||||
}
|
}
|
||||||
@ -550,7 +525,7 @@ describe('git user-agent with orchestration ID', () => {
|
|||||||
capturedEnv = options.env
|
capturedEnv = options.env
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
// exec.exec is already mockExec
|
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
||||||
|
|
||||||
const workingDirectory = 'test'
|
const workingDirectory = 'test'
|
||||||
const lfs = false
|
const lfs = false
|
||||||
|
|||||||
@ -1,36 +1,9 @@
|
|||||||
import {
|
import * as core from '@actions/core'
|
||||||
jest,
|
|
||||||
describe,
|
|
||||||
it,
|
|
||||||
expect,
|
|
||||||
beforeAll,
|
|
||||||
beforeEach,
|
|
||||||
afterEach
|
|
||||||
} from '@jest/globals'
|
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
import * as gitDirectoryHelper from '../lib/git-directory-helper'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {fileURLToPath} from 'url'
|
import {IGitCommandManager} from '../lib/git-command-manager'
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
||||||
|
|
||||||
// Mock @actions/core before loading git-directory-helper
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
error: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
info: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
setFailed: jest.fn(),
|
|
||||||
startGroup: jest.fn(),
|
|
||||||
endGroup: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const core = await import('@actions/core')
|
|
||||||
const gitDirectoryHelper = await import('../src/git-directory-helper.js')
|
|
||||||
|
|
||||||
type IGitCommandManager =
|
|
||||||
import('../src/git-command-manager.js').IGitCommandManager
|
|
||||||
|
|
||||||
const testWorkspace = path.join(__dirname, '_temp', 'git-directory-helper')
|
const testWorkspace = path.join(__dirname, '_temp', 'git-directory-helper')
|
||||||
let repositoryPath: string
|
let repositoryPath: string
|
||||||
@ -46,11 +19,16 @@ describe('git-directory-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks()
|
// Mock error/warning/info/debug
|
||||||
|
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks()
|
// Unregister mocks
|
||||||
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
const cleansWhenCleanTrue = 'cleans when clean true'
|
const cleansWhenCleanTrue = 'cleans when clean true'
|
||||||
@ -103,7 +81,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(doesNotCheckoutDetachWhenNotAlreadyDetached)
|
await setup(doesNotCheckoutDetachWhenNotAlreadyDetached)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
const mockIsDetached = git.isDetached as jest.Mock<any>
|
const mockIsDetached = git.isDetached as jest.Mock<any, any>
|
||||||
mockIsDetached.mockImplementation(async () => {
|
mockIsDetached.mockImplementation(async () => {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -154,7 +132,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(removesContentsWhenCleanFails)
|
await setup(removesContentsWhenCleanFails)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
let mockTryClean = git.tryClean as jest.Mock<any>
|
let mockTryClean = git.tryClean as jest.Mock<any, any>
|
||||||
mockTryClean.mockImplementation(async () => {
|
mockTryClean.mockImplementation(async () => {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
@ -232,7 +210,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(removesContentsWhenResetFails)
|
await setup(removesContentsWhenResetFails)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
let mockTryReset = git.tryReset as jest.Mock<any>
|
let mockTryReset = git.tryReset as jest.Mock<any, any>
|
||||||
mockTryReset.mockImplementation(async () => {
|
mockTryReset.mockImplementation(async () => {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
@ -282,7 +260,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(removesLocalBranches)
|
await setup(removesLocalBranches)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
const mockBranchList = git.branchList as jest.Mock<any>
|
const mockBranchList = git.branchList as jest.Mock<any, any>
|
||||||
mockBranchList.mockImplementation(async (remote: boolean) => {
|
mockBranchList.mockImplementation(async (remote: boolean) => {
|
||||||
return remote ? [] : ['local-branch-1', 'local-branch-2']
|
return remote ? [] : ['local-branch-1', 'local-branch-2']
|
||||||
})
|
})
|
||||||
@ -313,7 +291,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
|
|
||||||
//mock bad submodule
|
//mock bad submodule
|
||||||
|
|
||||||
const submoduleStatus = git.submoduleStatus as jest.Mock<any>
|
const submoduleStatus = git.submoduleStatus as jest.Mock<any, any>
|
||||||
submoduleStatus.mockImplementation(async (remote: boolean) => {
|
submoduleStatus.mockImplementation(async (remote: boolean) => {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
@ -341,7 +319,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
await setup(doesNotCleanWhenSubmoduleStatusIsTrue)
|
await setup(doesNotCleanWhenSubmoduleStatusIsTrue)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
|
|
||||||
const submoduleStatus = git.submoduleStatus as jest.Mock<any>
|
const submoduleStatus = git.submoduleStatus as jest.Mock<any, any>
|
||||||
submoduleStatus.mockImplementation(async (remote: boolean) => {
|
submoduleStatus.mockImplementation(async (remote: boolean) => {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -403,7 +381,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(removesAncestorRemoteBranch)
|
await setup(removesAncestorRemoteBranch)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
const mockBranchList = git.branchList as jest.Mock<any>
|
const mockBranchList = git.branchList as jest.Mock<any, any>
|
||||||
mockBranchList.mockImplementation(async (remote: boolean) => {
|
mockBranchList.mockImplementation(async (remote: boolean) => {
|
||||||
return remote ? ['origin/remote-branch-1', 'origin/remote-branch-2'] : []
|
return remote ? ['origin/remote-branch-1', 'origin/remote-branch-2'] : []
|
||||||
})
|
})
|
||||||
@ -433,7 +411,7 @@ describe('git-directory-helper tests', () => {
|
|||||||
// Arrange
|
// Arrange
|
||||||
await setup(removesDescendantRemoteBranches)
|
await setup(removesDescendantRemoteBranches)
|
||||||
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
|
||||||
const mockBranchList = git.branchList as jest.Mock<any>
|
const mockBranchList = git.branchList as jest.Mock<any, any>
|
||||||
mockBranchList.mockImplementation(async (remote: boolean) => {
|
mockBranchList.mockImplementation(async (remote: boolean) => {
|
||||||
return remote
|
return remote
|
||||||
? ['origin/remote-branch-1/conflict', 'origin/remote-branch-2']
|
? ['origin/remote-branch-1/conflict', 'origin/remote-branch-2']
|
||||||
@ -529,5 +507,5 @@ async function setup(testName: string): Promise<void> {
|
|||||||
return true
|
return true
|
||||||
}),
|
}),
|
||||||
version: jest.fn()
|
version: jest.fn()
|
||||||
} as unknown as IGitCommandManager
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import {describe, it, expect} from '@jest/globals'
|
import {GitVersion} from '../src/git-version'
|
||||||
import {GitVersion} from '../src/git-version.js'
|
import {MinimumGitSparseCheckoutVersion} from '../src/git-command-manager'
|
||||||
import {MinimumGitSparseCheckoutVersion} from '../src/git-command-manager.js'
|
|
||||||
|
|
||||||
describe('git-version tests', () => {
|
describe('git-version tests', () => {
|
||||||
it('basics', async () => {
|
it('basics', async () => {
|
||||||
|
|||||||
@ -1,25 +1,11 @@
|
|||||||
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals'
|
import * as core from '@actions/core'
|
||||||
|
import * as github from '@actions/github'
|
||||||
// Mock @actions/core
|
import * as githubApiHelper from '../lib/github-api-helper'
|
||||||
const mockDebug = jest.fn()
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
debug: mockDebug,
|
|
||||||
info: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
error: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock @actions/github
|
|
||||||
const mockGetOctokit = jest.fn()
|
|
||||||
jest.unstable_mockModule('@actions/github', () => ({
|
|
||||||
getOctokit: mockGetOctokit
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const githubApiHelper = await import('../src/github-api-helper.js')
|
|
||||||
|
|
||||||
describe('github-api-helper object format', () => {
|
describe('github-api-helper object format', () => {
|
||||||
let request: jest.Mock<any>
|
let getOctokitSpy: jest.SpyInstance
|
||||||
|
let debugSpy: jest.SpyInstance
|
||||||
|
let request: jest.Mock
|
||||||
|
|
||||||
function mockHashAlgorithmApi(hashAlgorithm: string): void {
|
function mockHashAlgorithmApi(hashAlgorithm: string): void {
|
||||||
request = jest.fn(async () => ({
|
request = jest.fn(async () => ({
|
||||||
@ -27,18 +13,17 @@ describe('github-api-helper object format', () => {
|
|||||||
hash_algorithm: hashAlgorithm
|
hash_algorithm: hashAlgorithm
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
mockGetOctokit.mockReturnValue({
|
getOctokitSpy = jest.spyOn(github, 'getOctokit').mockReturnValue({
|
||||||
request
|
request
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockDebug.mockClear()
|
debugSpy = jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
mockGetOctokit.mockClear()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('detects SHA-256 from the repository hash algorithm endpoint', async () => {
|
it('detects SHA-256 from the repository hash algorithm endpoint', async () => {
|
||||||
@ -48,7 +33,7 @@ describe('github-api-helper object format', () => {
|
|||||||
githubApiHelper.tryGetRepositoryObjectFormat('token', 'owner', 'repo')
|
githubApiHelper.tryGetRepositoryObjectFormat('token', 'owner', 'repo')
|
||||||
).resolves.toEqual({format: 'sha256', succeeded: true})
|
).resolves.toEqual({format: 'sha256', succeeded: true})
|
||||||
|
|
||||||
expect(mockGetOctokit).toHaveBeenCalledWith(
|
expect(getOctokitSpy).toHaveBeenCalledWith(
|
||||||
'token',
|
'token',
|
||||||
expect.objectContaining({baseUrl: 'https://api.github.com'})
|
expect.objectContaining({baseUrl: 'https://api.github.com'})
|
||||||
)
|
)
|
||||||
@ -69,6 +54,7 @@ describe('github-api-helper object format', () => {
|
|||||||
it('detects object format from an existing commit without API calls', async () => {
|
it('detects object format from an existing commit without API calls', async () => {
|
||||||
const commitSha =
|
const commitSha =
|
||||||
'9422233ca7ee1b17f1e905d0e141faf0c401556c41cdc6acd71c6bd685da2e92'
|
'9422233ca7ee1b17f1e905d0e141faf0c401556c41cdc6acd71c6bd685da2e92'
|
||||||
|
getOctokitSpy = jest.spyOn(github, 'getOctokit')
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
githubApiHelper.tryGetRepositoryObjectFormat(
|
githubApiHelper.tryGetRepositoryObjectFormat(
|
||||||
@ -80,7 +66,7 @@ describe('github-api-helper object format', () => {
|
|||||||
)
|
)
|
||||||
).resolves.toEqual({format: 'sha256', succeeded: true})
|
).resolves.toEqual({format: 'sha256', succeeded: true})
|
||||||
|
|
||||||
expect(mockGetOctokit).not.toHaveBeenCalled()
|
expect(getOctokitSpy).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns unsuccessful when the hash algorithm endpoint value is not recognized', async () => {
|
it('returns unsuccessful when the hash algorithm endpoint value is not recognized', async () => {
|
||||||
@ -89,7 +75,7 @@ describe('github-api-helper object format', () => {
|
|||||||
await expect(
|
await expect(
|
||||||
githubApiHelper.tryGetRepositoryObjectFormat('token', 'owner', 'repo')
|
githubApiHelper.tryGetRepositoryObjectFormat('token', 'owner', 'repo')
|
||||||
).resolves.toEqual({format: '', succeeded: false})
|
).resolves.toEqual({format: '', succeeded: false})
|
||||||
expect(mockDebug).toHaveBeenCalledWith(
|
expect(debugSpy).toHaveBeenCalledWith(
|
||||||
'Unable to determine repository object format from hash-algorithm endpoint'
|
'Unable to determine repository object format from hash-algorithm endpoint'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -98,14 +84,14 @@ describe('github-api-helper object format', () => {
|
|||||||
request = jest.fn(async () => {
|
request = jest.fn(async () => {
|
||||||
throw new Error('not found')
|
throw new Error('not found')
|
||||||
})
|
})
|
||||||
mockGetOctokit.mockReturnValue({
|
jest.spyOn(github, 'getOctokit').mockReturnValue({
|
||||||
request
|
request
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
githubApiHelper.tryGetRepositoryObjectFormat('token', 'owner', 'repo')
|
githubApiHelper.tryGetRepositoryObjectFormat('token', 'owner', 'repo')
|
||||||
).resolves.toEqual({format: '', succeeded: false})
|
).resolves.toEqual({format: '', succeeded: false})
|
||||||
expect(mockDebug).toHaveBeenCalledWith(
|
expect(debugSpy).toHaveBeenCalledWith(
|
||||||
'Unable to determine repository object format from hash-algorithm endpoint: not found'
|
'Unable to determine repository object format from hash-algorithm endpoint: not found'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
import {
|
import * as core from '@actions/core'
|
||||||
jest,
|
import * as fsHelper from '../lib/fs-helper'
|
||||||
describe,
|
import * as github from '@actions/github'
|
||||||
it,
|
import * as inputHelper from '../lib/input-helper'
|
||||||
expect,
|
|
||||||
beforeAll,
|
|
||||||
beforeEach,
|
|
||||||
afterAll
|
|
||||||
} from '@jest/globals'
|
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import * as workflowContextHelper from '../lib/workflow-context-helper'
|
||||||
|
import {IGitSourceSettings} from '../lib/git-source-settings'
|
||||||
|
|
||||||
const originalGitHubWorkspace = process.env['GITHUB_WORKSPACE']
|
const originalGitHubWorkspace = process.env['GITHUB_WORKSPACE']
|
||||||
const gitHubWorkspace = path.resolve('/checkout-tests/workspace')
|
const gitHubWorkspace = path.resolve('/checkout-tests/workspace')
|
||||||
@ -15,58 +12,42 @@ const gitHubWorkspace = path.resolve('/checkout-tests/workspace')
|
|||||||
// Inputs for mock @actions/core
|
// Inputs for mock @actions/core
|
||||||
let inputs = {} as any
|
let inputs = {} as any
|
||||||
|
|
||||||
// Mutable mock github context
|
// Shallow clone original @actions/github context
|
||||||
const mockGithubContext: any = {
|
let originalContext = {...github.context}
|
||||||
ref: 'refs/heads/some-ref',
|
|
||||||
sha: '1234567890123456789012345678901234567890',
|
|
||||||
repo: {owner: 'some-owner', repo: 'some-repo'},
|
|
||||||
eventName: '',
|
|
||||||
payload: {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mock @actions/core before loading input-helper
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
getInput: jest.fn((name: string) => inputs[name]),
|
|
||||||
getBooleanInput: jest.fn((name: string) => inputs[name]),
|
|
||||||
getMultilineInput: jest.fn((name: string) =>
|
|
||||||
inputs[name] ? String(inputs[name]).split('\n').filter(Boolean) : []
|
|
||||||
),
|
|
||||||
error: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
info: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
setFailed: jest.fn(),
|
|
||||||
setOutput: jest.fn(),
|
|
||||||
setSecret: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock @actions/github before loading input-helper
|
|
||||||
jest.unstable_mockModule('@actions/github', () => ({
|
|
||||||
context: mockGithubContext,
|
|
||||||
getOctokit: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock fs-helper
|
|
||||||
const mockDirectoryExistsSync = jest.fn((p: string) => p === gitHubWorkspace)
|
|
||||||
jest.unstable_mockModule('../src/fs-helper.js', () => ({
|
|
||||||
directoryExistsSync: mockDirectoryExistsSync,
|
|
||||||
fileExistsSync: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock workflow-context-helper
|
|
||||||
const mockGetOrganizationId = jest.fn(async () => 123456)
|
|
||||||
jest.unstable_mockModule('../src/workflow-context-helper.js', () => ({
|
|
||||||
getOrganizationId: mockGetOrganizationId
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const core = await import('@actions/core')
|
|
||||||
const inputHelper = await import('../src/input-helper.js')
|
|
||||||
type IGitSourceSettings =
|
|
||||||
import('../src/git-source-settings.js').IGitSourceSettings
|
|
||||||
|
|
||||||
describe('input-helper tests', () => {
|
describe('input-helper tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
// Mock getInput
|
||||||
|
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||||
|
return inputs[name]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Mock error/warning/info/debug
|
||||||
|
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
|
|
||||||
|
// Mock github context
|
||||||
|
jest.spyOn(github.context, 'repo', 'get').mockImplementation(() => {
|
||||||
|
return {
|
||||||
|
owner: 'some-owner',
|
||||||
|
repo: 'some-repo'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
github.context.ref = 'refs/heads/some-ref'
|
||||||
|
github.context.sha = '1234567890123456789012345678901234567890'
|
||||||
|
|
||||||
|
// Mock ./fs-helper directoryExistsSync()
|
||||||
|
jest
|
||||||
|
.spyOn(fsHelper, 'directoryExistsSync')
|
||||||
|
.mockImplementation((path: string) => path == gitHubWorkspace)
|
||||||
|
|
||||||
|
// Mock ./workflowContextHelper getOrganizationId()
|
||||||
|
jest
|
||||||
|
.spyOn(workflowContextHelper, 'getOrganizationId')
|
||||||
|
.mockImplementation(() => Promise.resolve(123456))
|
||||||
|
|
||||||
// GitHub workspace
|
// GitHub workspace
|
||||||
process.env['GITHUB_WORKSPACE'] = gitHubWorkspace
|
process.env['GITHUB_WORKSPACE'] = gitHubWorkspace
|
||||||
})
|
})
|
||||||
@ -74,15 +55,6 @@ describe('input-helper tests', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Reset inputs
|
// Reset inputs
|
||||||
inputs = {}
|
inputs = {}
|
||||||
jest.clearAllMocks()
|
|
||||||
// Re-apply default mocks
|
|
||||||
;(core.getInput as jest.Mock<any>).mockImplementation(
|
|
||||||
(name: string) => inputs[name]
|
|
||||||
)
|
|
||||||
mockDirectoryExistsSync.mockImplementation(
|
|
||||||
(p: string) => p === gitHubWorkspace
|
|
||||||
)
|
|
||||||
mockGetOrganizationId.mockResolvedValue(123456)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
@ -93,8 +65,11 @@ describe('input-helper tests', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore @actions/github context
|
// Restore @actions/github context
|
||||||
mockGithubContext.ref = 'refs/heads/some-ref'
|
github.context.ref = originalContext.ref
|
||||||
mockGithubContext.sha = '1234567890123456789012345678901234567890'
|
github.context.sha = originalContext.sha
|
||||||
|
|
||||||
|
// Restore
|
||||||
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets defaults', async () => {
|
it('sets defaults', async () => {
|
||||||
@ -120,15 +95,15 @@ describe('input-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('qualifies ref', async () => {
|
it('qualifies ref', async () => {
|
||||||
let originalRef = mockGithubContext.ref
|
let originalRef = github.context.ref
|
||||||
try {
|
try {
|
||||||
mockGithubContext.ref = 'some-unqualified-ref'
|
github.context.ref = 'some-unqualified-ref'
|
||||||
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
expect(settings).toBeTruthy()
|
expect(settings).toBeTruthy()
|
||||||
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
|
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
|
||||||
expect(settings.ref).toBe('refs/heads/some-unqualified-ref')
|
expect(settings.ref).toBe('refs/heads/some-unqualified-ref')
|
||||||
} finally {
|
} finally {
|
||||||
mockGithubContext.ref = originalRef
|
github.context.ref = originalRef
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,36 +1,8 @@
|
|||||||
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals'
|
|
||||||
import * as assert from 'assert'
|
import * as assert from 'assert'
|
||||||
|
import * as core from '@actions/core'
|
||||||
// Mutable mock github context
|
import * as github from '@actions/github'
|
||||||
const mockGithubContext: any = {
|
import * as refHelper from '../lib/ref-helper'
|
||||||
eventName: '',
|
import {IGitCommandManager} from '../lib/git-command-manager'
|
||||||
payload: {},
|
|
||||||
repo: {owner: 'some-owner', repo: 'some-repo'},
|
|
||||||
ref: '',
|
|
||||||
sha: ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mock @actions/core
|
|
||||||
const mockDebug = jest.fn()
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
debug: mockDebug,
|
|
||||||
info: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
error: jest.fn(),
|
|
||||||
setFailed: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Mock @actions/github
|
|
||||||
const mockGetOctokit = jest.fn()
|
|
||||||
jest.unstable_mockModule('@actions/github', () => ({
|
|
||||||
context: mockGithubContext,
|
|
||||||
getOctokit: mockGetOctokit
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const refHelper = await import('../src/ref-helper.js')
|
|
||||||
type IGitCommandManager =
|
|
||||||
import('../src/git-command-manager.js').IGitCommandManager
|
|
||||||
|
|
||||||
const commit = '1234567890123456789012345678901234567890'
|
const commit = '1234567890123456789012345678901234567890'
|
||||||
const sha256Commit =
|
const sha256Commit =
|
||||||
@ -40,7 +12,6 @@ let git: IGitCommandManager
|
|||||||
describe('ref-helper tests', () => {
|
describe('ref-helper tests', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
git = {} as unknown as IGitCommandManager
|
git = {} as unknown as IGitCommandManager
|
||||||
jest.clearAllMocks()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getCheckoutInfo requires git', async () => {
|
it('getCheckoutInfo requires git', async () => {
|
||||||
@ -195,12 +166,14 @@ describe('ref-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('getRefSpec sha + refs/tags/ with fetchTags', async () => {
|
it('getRefSpec sha + refs/tags/ with fetchTags', async () => {
|
||||||
|
// When fetchTags is true, only include tags wildcard (specific tag is redundant)
|
||||||
const refSpec = refHelper.getRefSpec('refs/tags/my-tag', commit, true)
|
const refSpec = refHelper.getRefSpec('refs/tags/my-tag', commit, true)
|
||||||
expect(refSpec.length).toBe(1)
|
expect(refSpec.length).toBe(1)
|
||||||
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getRefSpec sha + refs/heads/ with fetchTags', async () => {
|
it('getRefSpec sha + refs/heads/ with fetchTags', async () => {
|
||||||
|
// When fetchTags is true, include both the branch refspec and tags wildcard
|
||||||
const refSpec = refHelper.getRefSpec('refs/heads/my/branch', commit, true)
|
const refSpec = refHelper.getRefSpec('refs/heads/my/branch', commit, true)
|
||||||
expect(refSpec.length).toBe(2)
|
expect(refSpec.length).toBe(2)
|
||||||
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
||||||
@ -221,6 +194,7 @@ describe('ref-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('getRefSpec unqualified ref only with fetchTags', async () => {
|
it('getRefSpec unqualified ref only with fetchTags', async () => {
|
||||||
|
// When fetchTags is true, skip specific tag pattern since wildcard covers all
|
||||||
const refSpec = refHelper.getRefSpec('my-ref', '', true)
|
const refSpec = refHelper.getRefSpec('my-ref', '', true)
|
||||||
expect(refSpec.length).toBe(2)
|
expect(refSpec.length).toBe(2)
|
||||||
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
||||||
@ -248,12 +222,14 @@ describe('ref-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('getRefSpec refs/tags/ only with fetchTags', async () => {
|
it('getRefSpec refs/tags/ only with fetchTags', async () => {
|
||||||
|
// When fetchTags is true, only include tags wildcard (specific tag is redundant)
|
||||||
const refSpec = refHelper.getRefSpec('refs/tags/my-tag', '', true)
|
const refSpec = refHelper.getRefSpec('refs/tags/my-tag', '', true)
|
||||||
expect(refSpec.length).toBe(1)
|
expect(refSpec.length).toBe(1)
|
||||||
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getRefSpec refs/heads/ only with fetchTags', async () => {
|
it('getRefSpec refs/heads/ only with fetchTags', async () => {
|
||||||
|
// When fetchTags is true, include both the branch refspec and tags wildcard
|
||||||
const refSpec = refHelper.getRefSpec('refs/heads/my/branch', '', true)
|
const refSpec = refHelper.getRefSpec('refs/heads/my/branch', '', true)
|
||||||
expect(refSpec.length).toBe(2)
|
expect(refSpec.length).toBe(2)
|
||||||
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
expect(refSpec[0]).toBe('+refs/tags/*:refs/tags/*')
|
||||||
@ -272,7 +248,9 @@ describe('ref-helper tests', () => {
|
|||||||
'1111111111222222222233333333334444444444555555555566666666667777'
|
'1111111111222222222233333333334444444444555555555566666666667777'
|
||||||
const sha256Base =
|
const sha256Base =
|
||||||
'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff0000'
|
'aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff0000'
|
||||||
let repoGetSpy: jest.Mock<any>
|
let debugSpy: jest.SpyInstance
|
||||||
|
let getOctokitSpy: jest.SpyInstance
|
||||||
|
let repoGetSpy: jest.Mock
|
||||||
let originalEventName: string
|
let originalEventName: string
|
||||||
let originalPayload: unknown
|
let originalPayload: unknown
|
||||||
let originalRef: string
|
let originalRef: string
|
||||||
@ -283,10 +261,10 @@ describe('ref-helper tests', () => {
|
|||||||
expectedBaseSha: string,
|
expectedBaseSha: string,
|
||||||
mergeCommit: string
|
mergeCommit: string
|
||||||
): void {
|
): void {
|
||||||
mockGithubContext.eventName = 'pull_request'
|
;(github.context as any).eventName = 'pull_request'
|
||||||
mockGithubContext.ref = ref
|
github.context.ref = ref
|
||||||
mockGithubContext.sha = mergeCommit
|
github.context.sha = mergeCommit
|
||||||
mockGithubContext.payload = {
|
;(github.context as any).payload = {
|
||||||
action: 'synchronize',
|
action: 'synchronize',
|
||||||
after: expectedHeadSha,
|
after: expectedHeadSha,
|
||||||
number: 123,
|
number: 123,
|
||||||
@ -302,18 +280,18 @@ describe('ref-helper tests', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
originalEventName = mockGithubContext.eventName
|
originalEventName = github.context.eventName
|
||||||
originalPayload = mockGithubContext.payload
|
originalPayload = github.context.payload
|
||||||
originalRef = mockGithubContext.ref
|
originalRef = github.context.ref
|
||||||
originalSha = mockGithubContext.sha
|
originalSha = github.context.sha
|
||||||
|
|
||||||
mockGithubContext.repo = {
|
jest.spyOn(github.context, 'repo', 'get').mockReturnValue({
|
||||||
owner: repositoryOwner,
|
owner: repositoryOwner,
|
||||||
repo: repositoryName
|
repo: repositoryName
|
||||||
}
|
})
|
||||||
|
debugSpy = jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
repoGetSpy = jest.fn(async () => ({}))
|
repoGetSpy = jest.fn(async () => ({}))
|
||||||
mockGetOctokit.mockReturnValue({
|
getOctokitSpy = jest.spyOn(github, 'getOctokit').mockReturnValue({
|
||||||
rest: {
|
rest: {
|
||||||
repos: {
|
repos: {
|
||||||
get: repoGetSpy
|
get: repoGetSpy
|
||||||
@ -323,11 +301,11 @@ describe('ref-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mockGithubContext.eventName = originalEventName
|
;(github.context as any).eventName = originalEventName
|
||||||
mockGithubContext.payload = originalPayload
|
;(github.context as any).payload = originalPayload
|
||||||
mockGithubContext.ref = originalRef
|
github.context.ref = originalRef
|
||||||
mockGithubContext.sha = originalSha
|
github.context.sha = originalSha
|
||||||
jest.clearAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns early for SHA-1 merge commit', async () => {
|
it('returns early for SHA-1 merge commit', async () => {
|
||||||
@ -342,7 +320,7 @@ describe('ref-helper tests', () => {
|
|||||||
commit
|
commit
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(mockGetOctokit).not.toHaveBeenCalled()
|
expect(getOctokitSpy).not.toHaveBeenCalled()
|
||||||
expect(repoGetSpy).not.toHaveBeenCalled()
|
expect(repoGetSpy).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -360,7 +338,7 @@ describe('ref-helper tests', () => {
|
|||||||
sha256Commit
|
sha256Commit
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(mockGetOctokit).toHaveBeenCalledWith(
|
expect(getOctokitSpy).toHaveBeenCalledWith(
|
||||||
'token',
|
'token',
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
userAgent: expect.stringContaining(
|
userAgent: expect.stringContaining(
|
||||||
@ -372,10 +350,10 @@ describe('ref-helper tests', () => {
|
|||||||
owner: repositoryOwner,
|
owner: repositoryOwner,
|
||||||
repo: repositoryName
|
repo: repositoryName
|
||||||
})
|
})
|
||||||
expect(mockDebug).toHaveBeenCalledWith(
|
expect(debugSpy).toHaveBeenCalledWith(
|
||||||
`Expected head sha ${sha256Head}; actual head sha ${actualHeadSha}`
|
`Expected head sha ${sha256Head}; actual head sha ${actualHeadSha}`
|
||||||
)
|
)
|
||||||
expect(mockDebug).not.toHaveBeenCalledWith('Unexpected message format')
|
expect(debugSpy).not.toHaveBeenCalledWith('Unexpected message format')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not match 50-char hex as a valid merge', async () => {
|
it('does not match 50-char hex as a valid merge', async () => {
|
||||||
@ -392,9 +370,9 @@ describe('ref-helper tests', () => {
|
|||||||
commit
|
commit
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(mockGetOctokit).not.toHaveBeenCalled()
|
expect(getOctokitSpy).not.toHaveBeenCalled()
|
||||||
expect(repoGetSpy).not.toHaveBeenCalled()
|
expect(repoGetSpy).not.toHaveBeenCalled()
|
||||||
expect(mockDebug).toHaveBeenCalledWith('Unexpected message format')
|
expect(debugSpy).toHaveBeenCalledWith('Unexpected message format')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,32 +1,16 @@
|
|||||||
import {
|
import * as core from '@actions/core'
|
||||||
jest,
|
import {RetryHelper} from '../lib/retry-helper'
|
||||||
describe,
|
|
||||||
it,
|
|
||||||
expect,
|
|
||||||
beforeAll,
|
|
||||||
beforeEach,
|
|
||||||
afterAll
|
|
||||||
} from '@jest/globals'
|
|
||||||
|
|
||||||
let info: string[] = []
|
|
||||||
|
|
||||||
// Mock @actions/core before loading retry-helper
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
info: jest.fn((message: string) => {
|
|
||||||
info.push(message)
|
|
||||||
}),
|
|
||||||
debug: jest.fn(),
|
|
||||||
warning: jest.fn(),
|
|
||||||
error: jest.fn()
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const {RetryHelper} = await import('../src/retry-helper.js')
|
|
||||||
|
|
||||||
|
let info: string[]
|
||||||
let retryHelper: any
|
let retryHelper: any
|
||||||
|
|
||||||
describe('retry-helper tests', () => {
|
describe('retry-helper tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
// Mock @actions/core info()
|
||||||
|
jest.spyOn(core, 'info').mockImplementation((message: string) => {
|
||||||
|
info.push(message)
|
||||||
|
})
|
||||||
|
|
||||||
retryHelper = new RetryHelper(3, 0, 0)
|
retryHelper = new RetryHelper(3, 0, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -36,6 +20,7 @@ describe('retry-helper tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
// Restore
|
||||||
jest.restoreAllMocks()
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
import {
|
import * as github from '@actions/github'
|
||||||
jest,
|
import {assertSafePrCheckout} from '../lib/unsafe-pr-checkout-helper'
|
||||||
describe,
|
|
||||||
it,
|
// Shallow clone original @actions/github context
|
||||||
expect,
|
const originalContext = {...github.context}
|
||||||
beforeAll,
|
const originalEventName = github.context.eventName
|
||||||
afterEach,
|
const originalPayload = github.context.payload
|
||||||
afterAll
|
|
||||||
} from '@jest/globals'
|
|
||||||
|
|
||||||
const BASE_REPO_ID = 100
|
const BASE_REPO_ID = 100
|
||||||
const FORK_REPO_ID = 200
|
const FORK_REPO_ID = 200
|
||||||
@ -17,29 +15,9 @@ const WORKFLOW_RUN_HEAD_COMMIT_SHA = '4444444444444444444444444444444444444444'
|
|||||||
const BASE_QUALIFIED_REPO = 'some-owner/some-repo'
|
const BASE_QUALIFIED_REPO = 'some-owner/some-repo'
|
||||||
const FORK_QUALIFIED_REPO = 'another-repo/fork'
|
const FORK_QUALIFIED_REPO = 'another-repo/fork'
|
||||||
|
|
||||||
// Mutable mock context
|
|
||||||
const mockContext: any = {
|
|
||||||
eventName: '',
|
|
||||||
payload: {},
|
|
||||||
repo: {owner: 'some-owner', repo: 'some-repo'},
|
|
||||||
ref: '',
|
|
||||||
sha: ''
|
|
||||||
}
|
|
||||||
|
|
||||||
jest.unstable_mockModule('@actions/github', () => ({
|
|
||||||
context: mockContext
|
|
||||||
}))
|
|
||||||
|
|
||||||
// Dynamic imports after mocking
|
|
||||||
const {assertSafePrCheckout} =
|
|
||||||
await import('../src/unsafe-pr-checkout-helper.js')
|
|
||||||
|
|
||||||
const originalEventName = mockContext.eventName
|
|
||||||
const originalPayload = mockContext.payload
|
|
||||||
|
|
||||||
function setContext(eventName: string, payload: object): void {
|
function setContext(eventName: string, payload: object): void {
|
||||||
mockContext.eventName = eventName
|
;(github.context as {eventName: string}).eventName = eventName
|
||||||
mockContext.payload = payload
|
;(github.context as {payload: object}).payload = payload
|
||||||
}
|
}
|
||||||
|
|
||||||
function forkPullRequestTargetPayload(): object {
|
function forkPullRequestTargetPayload(): object {
|
||||||
@ -81,17 +59,22 @@ function forkWorkflowRunPayload(): object {
|
|||||||
|
|
||||||
describe('unsafe-pr-checkout-helper', () => {
|
describe('unsafe-pr-checkout-helper', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
mockContext.repo = {owner: 'some-owner', repo: 'some-repo'}
|
jest.spyOn(github.context, 'repo', 'get').mockReturnValue({
|
||||||
|
owner: 'some-owner',
|
||||||
|
repo: 'some-repo'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mockContext.eventName = originalEventName
|
;(github.context as {eventName: string}).eventName = originalEventName
|
||||||
mockContext.payload = originalPayload
|
;(github.context as {payload: object}).payload = originalPayload
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
mockContext.eventName = originalEventName
|
;(github.context as {eventName: string}).eventName =
|
||||||
mockContext.payload = originalPayload
|
originalContext.eventName
|
||||||
|
;(github.context as {payload: object}).payload = originalContext.payload
|
||||||
|
jest.restoreAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('allows pull_request events untouched', () => {
|
it('allows pull_request events untouched', () => {
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import {jest, describe, it, expect, beforeEach, afterAll} from '@jest/globals'
|
import * as urlHelper from '../src/url-helper'
|
||||||
import * as urlHelper from '../src/url-helper.js'
|
|
||||||
|
|
||||||
describe('getServerUrl tests', () => {
|
describe('getServerUrl tests', () => {
|
||||||
it('basics', async () => {
|
it('basics', async () => {
|
||||||
|
|||||||
53141
dist/index.js
vendored
53141
dist/index.js
vendored
File diff suppressed because one or more lines are too long
3
dist/package.json
vendored
3
dist/package.json
vendored
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
||||||
12
jest.config.js
Normal file
12
jest.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = {
|
||||||
|
clearMocks: true,
|
||||||
|
fakeTimers: {},
|
||||||
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
|
testEnvironment: 'node',
|
||||||
|
testMatch: ['**/*.test.ts'],
|
||||||
|
testRunner: 'jest-circus/runner',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.ts$': 'ts-jest'
|
||||||
|
},
|
||||||
|
verbose: true
|
||||||
|
}
|
||||||
@ -1,24 +0,0 @@
|
|||||||
export default {
|
|
||||||
clearMocks: true,
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
roots: ['<rootDir>'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': [
|
|
||||||
'ts-jest',
|
|
||||||
{
|
|
||||||
useESM: true,
|
|
||||||
diagnostics: {
|
|
||||||
ignoreCodes: [151002]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
|
||||||
transformIgnorePatterns: ['node_modules/(?!(@actions)/)'],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1'
|
|
||||||
},
|
|
||||||
verbose: true
|
|
||||||
}
|
|
||||||
735
package-lock.json
generated
735
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@ -2,14 +2,13 @@
|
|||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"description": "checkout action",
|
"description": "checkout action",
|
||||||
"type": "module",
|
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && ncc build src/main.ts -o dist && node lib/misc/generate-docs.js",
|
"build": "tsc && ncc build && node lib/misc/generate-docs.js",
|
||||||
"format": "prettier --write '**/*.ts'",
|
"format": "prettier --write '**/*.ts'",
|
||||||
"format-check": "prettier --check '**/*.ts'",
|
"format-check": "prettier --check '**/*.ts'",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
"test": "jest",
|
||||||
"licensed-check": "src/misc/licensed-check.sh",
|
"licensed-check": "src/misc/licensed-check.sh",
|
||||||
"licensed-generate": "src/misc/licensed-generate.sh"
|
"licensed-generate": "src/misc/licensed-generate.sh"
|
||||||
},
|
},
|
||||||
@ -28,30 +27,29 @@
|
|||||||
"url": "https://github.com/actions/checkout/issues"
|
"url": "https://github.com/actions/checkout/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/checkout#readme",
|
"homepage": "https://github.com/actions/checkout#readme",
|
||||||
"engines": {
|
|
||||||
"node": ">=24"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^3.0.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^9.1.1",
|
"@actions/github": "^6.0.0",
|
||||||
"@actions/io": "^3.0.2",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^4.0.0"
|
"@actions/tool-cache": "^2.0.1",
|
||||||
|
"uuid": "^9.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^24.1.0",
|
"@types/node": "^24.1.0",
|
||||||
|
"@types/uuid": "^9.0.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
||||||
"@typescript-eslint/parser": "^7.9.0",
|
"@typescript-eslint/parser": "^7.9.0",
|
||||||
"@vercel/ncc": "^0.44.0",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-github": "^4.10.2",
|
"eslint-plugin-github": "^4.10.2",
|
||||||
"eslint-plugin-jest": "^28.8.2",
|
"eslint-plugin-jest": "^28.8.2",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"js-yaml": "^4.2.0",
|
"jest-circus": "^29.7.0",
|
||||||
"prettier": "^3.8.4",
|
"js-yaml": "^4.1.0",
|
||||||
"ts-jest": "^29.4.11",
|
"prettier": "^3.3.3",
|
||||||
"ts-node": "^10.9.2",
|
"ts-jest": "^29.2.5",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import * as fs from 'fs'
|
|||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as regexpHelper from './regexp-helper.js'
|
import * as regexpHelper from './regexp-helper'
|
||||||
import * as stateHelper from './state-helper.js'
|
import * as stateHelper from './state-helper'
|
||||||
import * as urlHelper from './url-helper.js'
|
import * as urlHelper from './url-helper'
|
||||||
import {randomUUID} from 'crypto'
|
import {v4 as uuid} from 'uuid'
|
||||||
import {IGitCommandManager} from './git-command-manager.js'
|
import {IGitCommandManager} from './git-command-manager'
|
||||||
import {IGitSourceSettings} from './git-source-settings.js'
|
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'
|
||||||
@ -90,7 +90,7 @@ class GitAuthHelper {
|
|||||||
// Create a temp home directory
|
// Create a temp home directory
|
||||||
const runnerTemp = process.env['RUNNER_TEMP'] || ''
|
const runnerTemp = process.env['RUNNER_TEMP'] || ''
|
||||||
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
||||||
const uniqueId = randomUUID()
|
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})
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ class GitAuthHelper {
|
|||||||
// Write key
|
// Write key
|
||||||
const runnerTemp = process.env['RUNNER_TEMP'] || ''
|
const runnerTemp = process.env['RUNNER_TEMP'] || ''
|
||||||
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
||||||
const uniqueId = randomUUID()
|
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})
|
||||||
@ -422,7 +422,7 @@ class GitAuthHelper {
|
|||||||
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
assert.ok(runnerTemp, 'RUNNER_TEMP is not defined')
|
||||||
|
|
||||||
// Create a unique filename for this checkout instance
|
// Create a unique filename for this checkout instance
|
||||||
const configFileName = `git-credentials-${randomUUID()}.config`
|
const configFileName = `git-credentials-${uuid()}.config`
|
||||||
this.credentialsConfigPath = path.join(runnerTemp, configFileName)
|
this.credentialsConfigPath = path.join(runnerTemp, configFileName)
|
||||||
|
|
||||||
core.debug(`Credentials config path: ${this.credentialsConfigPath}`)
|
core.debug(`Credentials config path: ${this.credentialsConfigPath}`)
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as fshelper from './fs-helper.js'
|
import * as fshelper from './fs-helper'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as refHelper from './ref-helper.js'
|
import * as refHelper from './ref-helper'
|
||||||
import * as regexpHelper from './regexp-helper.js'
|
import * as regexpHelper from './regexp-helper'
|
||||||
import * as retryHelper from './retry-helper.js'
|
import * as retryHelper from './retry-helper'
|
||||||
import {GitVersion} from './git-version.js'
|
import {GitVersion} from './git-version'
|
||||||
|
|
||||||
// Auth header not supported before 2.9
|
// Auth header not supported before 2.9
|
||||||
// Wire protocol v2 not supported before 2.18
|
// Wire protocol v2 not supported before 2.18
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import * as assert from 'assert'
|
import * as assert from 'assert'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as fsHelper from './fs-helper.js'
|
import * as fsHelper from './fs-helper'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {IGitCommandManager} from './git-command-manager.js'
|
import {IGitCommandManager} from './git-command-manager'
|
||||||
|
|
||||||
export async function prepareExistingDirectory(
|
export async function prepareExistingDirectory(
|
||||||
git: IGitCommandManager | undefined,
|
git: IGitCommandManager | undefined,
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as fsHelper from './fs-helper.js'
|
import * as fsHelper from './fs-helper'
|
||||||
import * as gitAuthHelper from './git-auth-helper.js'
|
import * as gitAuthHelper from './git-auth-helper'
|
||||||
import * as gitCommandManager from './git-command-manager.js'
|
import * as gitCommandManager from './git-command-manager'
|
||||||
import * as gitDirectoryHelper from './git-directory-helper.js'
|
import * as gitDirectoryHelper from './git-directory-helper'
|
||||||
import * as githubApiHelper from './github-api-helper.js'
|
import * as githubApiHelper from './github-api-helper'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as refHelper from './ref-helper.js'
|
import * as refHelper from './ref-helper'
|
||||||
import * as stateHelper from './state-helper.js'
|
import * as stateHelper from './state-helper'
|
||||||
import * as urlHelper from './url-helper.js'
|
import * as urlHelper from './url-helper'
|
||||||
import {
|
import {
|
||||||
MinimumGitSparseCheckoutVersion,
|
MinimumGitSparseCheckoutVersion,
|
||||||
IGitCommandManager
|
IGitCommandManager
|
||||||
} from './git-command-manager.js'
|
} from './git-command-manager'
|
||||||
import {IGitSourceSettings} from './git-source-settings.js'
|
import {IGitSourceSettings} from './git-source-settings'
|
||||||
|
|
||||||
export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
// Repository URL
|
// Repository URL
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import * as fs from 'fs'
|
|||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as retryHelper from './retry-helper.js'
|
import * as retryHelper from './retry-helper'
|
||||||
import * as toolCache from '@actions/tool-cache'
|
import * as toolCache from '@actions/tool-cache'
|
||||||
import {randomUUID} from 'crypto'
|
import {v4 as uuid} from 'uuid'
|
||||||
import {getServerApiUrl} from './url-helper.js'
|
import {getServerApiUrl} from './url-helper'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export async function downloadRepository(
|
|||||||
|
|
||||||
// Write archive to disk
|
// Write archive to disk
|
||||||
core.info('Writing archive to disk')
|
core.info('Writing archive to disk')
|
||||||
const uniqueId = randomUUID()
|
const uniqueId = uuid()
|
||||||
const archivePath = IS_WINDOWS
|
const archivePath = IS_WINDOWS
|
||||||
? path.join(repositoryPath, `${uniqueId}.zip`)
|
? path.join(repositoryPath, `${uniqueId}.zip`)
|
||||||
: path.join(repositoryPath, `${uniqueId}.tar.gz`)
|
: path.join(repositoryPath, `${uniqueId}.tar.gz`)
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as fsHelper from './fs-helper.js'
|
import * as fsHelper from './fs-helper'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as unsafePrCheckoutHelper from './unsafe-pr-checkout-helper.js'
|
import * as unsafePrCheckoutHelper from './unsafe-pr-checkout-helper'
|
||||||
import * as workflowContextHelper from './workflow-context-helper.js'
|
import * as workflowContextHelper from './workflow-context-helper'
|
||||||
import {IGitSourceSettings} from './git-source-settings.js'
|
import {IGitSourceSettings} from './git-source-settings'
|
||||||
|
|
||||||
export async function getInputs(): Promise<IGitSourceSettings> {
|
export async function getInputs(): Promise<IGitSourceSettings> {
|
||||||
const result = {} as unknown as IGitSourceSettings
|
const result = {} as unknown as IGitSourceSettings
|
||||||
|
|||||||
18
src/main.ts
18
src/main.ts
@ -1,11 +1,9 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as gitSourceProvider from './git-source-provider.js'
|
import * as coreCommand from '@actions/core/lib/command'
|
||||||
import * as inputHelper from './input-helper.js'
|
import * as gitSourceProvider from './git-source-provider'
|
||||||
|
import * as inputHelper from './input-helper'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as stateHelper from './state-helper.js'
|
import * as stateHelper from './state-helper'
|
||||||
import {fileURLToPath} from 'url'
|
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@ -13,8 +11,10 @@ async function run(): Promise<void> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Register problem matcher
|
// Register problem matcher
|
||||||
core.info(
|
coreCommand.issueCommand(
|
||||||
`::add-matcher::${path.join(__dirname, 'problem-matcher.json')}`
|
'add-matcher',
|
||||||
|
{},
|
||||||
|
path.join(__dirname, 'problem-matcher.json')
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get sources
|
// Get sources
|
||||||
@ -22,7 +22,7 @@ async function run(): Promise<void> {
|
|||||||
core.setOutput('ref', sourceSettings.ref)
|
core.setOutput('ref', sourceSettings.ref)
|
||||||
} finally {
|
} finally {
|
||||||
// Unregister problem matcher
|
// Unregister problem matcher
|
||||||
core.info('::remove-matcher owner=checkout-git::')
|
coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(`${(error as any)?.message ?? error}`)
|
core.setFailed(`${(error as any)?.message ?? error}`)
|
||||||
|
|||||||
@ -2,9 +2,6 @@ import * as fs from 'fs'
|
|||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as yaml from 'js-yaml'
|
import * as yaml from 'js-yaml'
|
||||||
import {fileURLToPath} from 'url'
|
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// SUMMARY
|
// SUMMARY
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import {IGitCommandManager} from './git-command-manager.js'
|
import {IGitCommandManager} from './git-command-manager'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import {getServerApiUrl, isGhes} from './url-helper.js'
|
import {getServerApiUrl, isGhes} from './url-helper'
|
||||||
|
|
||||||
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import {fromPayload} from './ref-helper.js'
|
import {fromPayload} from './ref-helper'
|
||||||
|
|
||||||
const PR_REF_PATTERN = /^refs\/pull\/[0-9]+\/(?:head|merge)$/
|
const PR_REF_PATTERN = /^refs\/pull\/[0-9]+\/(?:head|merge)$/
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import * as assert from 'assert'
|
import * as assert from 'assert'
|
||||||
import {URL} from 'url'
|
import {URL} from 'url'
|
||||||
import {IGitSourceSettings} from './git-source-settings.js'
|
import {IGitSourceSettings} from './git-source-settings'
|
||||||
|
|
||||||
export function getFetchUrl(settings: IGitSourceSettings): string {
|
export function getFetchUrl(settings: IGitSourceSettings): string {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2022",
|
"target": "es6",
|
||||||
"module": "NodeNext",
|
"module": "commonjs",
|
||||||
"moduleResolution": "NodeNext",
|
"lib": [
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
|
"declaration": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"exclude": ["__test__", "lib", "node_modules", "jest.config.ts"]
|
"exclude": ["__test__", "lib", "node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user