Compare commits

...

5 Commits

Author SHA1 Message Date
Jack Bates
0e6e193442
Merge f787e7d544c130d1f240b14444b0ce9724a4f6db into 11bd71901bbe5b1630ceea73d27597364c9af683 2024-10-23 12:57:06 -04:00
John Wesley Walker III
11bd71901b
Prepare 4.2.2 Release (#1953)
Some checks failed
Check dist / check-dist (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Licensed / Check licenses (push) Has been cancelled
Build and Test / build (push) Has been cancelled
Build and Test / test (macos-latest) (push) Has been cancelled
Build and Test / test (ubuntu-latest) (push) Has been cancelled
Build and Test / test (windows-latest) (push) Has been cancelled
Build and Test / test-proxy (push) Has been cancelled
Build and Test / test-bypass-proxy (push) Has been cancelled
Build and Test / test-git-container (push) Has been cancelled
Build and Test / test-output (push) Has been cancelled
* Prepare 4.2.2 Release

---------

Co-authored-by: Josh Gross <joshmgross@github.com>
2024-10-23 16:24:28 +02:00
John Wesley Walker III
e3d2460bbb
Expand unit test coverage (#1946) 2024-10-23 15:59:08 +02:00
Jack Bates
f787e7d544
Apply suggestions from code review
Co-authored-by: Usman <akeju00+github@gmail.com>
2023-10-06 06:25:44 -07:00
Jack Bates
d48599a299
Set default user.name and user.email 2021-09-15 09:59:02 -07:00
5 changed files with 53 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## v4.2.2
* `url-helper.ts` now leverages well-known environment variables by @jww3 in https://github.com/actions/checkout/pull/1941
* Expand unit test coverage for `isGhes` by @jww3 in https://github.com/actions/checkout/pull/1946
## v4.2.1 ## v4.2.1
* Check out other refs/* by commit if provided, fall back to ref by @orhantoy in https://github.com/actions/checkout/pull/1924 * Check out other refs/* by commit if provided, fall back to ref by @orhantoy in https://github.com/actions/checkout/pull/1924

View File

@ -24,13 +24,50 @@ describe('getServerUrl tests', () => {
}) })
describe('isGhes tests', () => { describe('isGhes tests', () => {
const pristineEnv = process.env
beforeEach(() => {
jest.resetModules()
process.env = {...pristineEnv}
})
afterAll(() => {
process.env = pristineEnv
})
it('basics', async () => { it('basics', async () => {
delete process.env['GITHUB_SERVER_URL']
expect(urlHelper.isGhes()).toBeFalsy() expect(urlHelper.isGhes()).toBeFalsy()
expect(urlHelper.isGhes('https://github.com')).toBeFalsy() expect(urlHelper.isGhes('https://github.com')).toBeFalsy()
expect(urlHelper.isGhes('https://contoso.ghe.com')).toBeFalsy() expect(urlHelper.isGhes('https://contoso.ghe.com')).toBeFalsy()
expect(urlHelper.isGhes('https://test.github.localhost')).toBeFalsy() expect(urlHelper.isGhes('https://test.github.localhost')).toBeFalsy()
expect(urlHelper.isGhes('https://src.onpremise.fabrikam.com')).toBeTruthy() expect(urlHelper.isGhes('https://src.onpremise.fabrikam.com')).toBeTruthy()
}) })
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
delete process.env['GITHUB_SERVER_URL']
expect(urlHelper.isGhes()).toBeFalsy()
})
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://github.com'
expect(urlHelper.isGhes()).toBeFalsy()
})
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com'
expect(urlHelper.isGhes()).toBeFalsy()
})
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost'
expect(urlHelper.isGhes()).toBeFalsy()
})
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com'
expect(urlHelper.isGhes()).toBeTruthy()
})
}) })
describe('getServerApiUrl tests', () => { describe('getServerApiUrl tests', () => {

4
package-lock.json generated
View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "checkout", "name": "checkout",
"version": "4.2.1", "version": "4.2.2",
"description": "checkout action", "description": "checkout action",
"main": "lib/main.js", "main": "lib/main.js",
"scripts": { "scripts": {

View File

@ -1,4 +1,5 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as github from '@actions/github'
import * as fsHelper from './fs-helper' import * as fsHelper from './fs-helper'
import * as gitAuthHelper from './git-auth-helper' import * as gitAuthHelper from './git-auth-helper'
import * as gitCommandManager from './git-command-manager' import * as gitCommandManager from './git-command-manager'
@ -274,6 +275,14 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
settings.commit, settings.commit,
settings.githubServerUrl settings.githubServerUrl
) )
// Set default author
if (!await git.configExists('user.name', true)) {
await git.config('user.name', github.context.workflow, true)
}
if (!await git.configExists('user.email', true)) {
await git.config('user.email', 'github-actions@github.com', true)
}
} finally { } finally {
// Remove auth // Remove auth
if (authHelper) { if (authHelper) {