mirror of
https://github.com/actions/checkout.git
synced 2025-04-01 22:10:06 +02:00
add the ability to disable core.autocrlf
This commit is contained in:
parent
25a956c84d
commit
931cbfe4af
5 changed files with 28 additions and 0 deletions
|
@ -68,6 +68,9 @@ inputs:
|
||||||
When the `ssh-key` input is not provided, SSH URLs beginning with `git@github.com:` are
|
When the `ssh-key` input is not provided, SSH URLs beginning with `git@github.com:` are
|
||||||
converted to HTTPS.
|
converted to HTTPS.
|
||||||
default: false
|
default: false
|
||||||
|
autocrlf:
|
||||||
|
description: 'Whether to disable core.autocrlf'
|
||||||
|
default: true
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
|
|
@ -44,6 +44,7 @@ export interface IGitCommandManager {
|
||||||
tryClean(): Promise<boolean>
|
tryClean(): Promise<boolean>
|
||||||
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
|
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
|
||||||
tryDisableAutomaticGarbageCollection(): Promise<boolean>
|
tryDisableAutomaticGarbageCollection(): Promise<boolean>
|
||||||
|
tryDisableAutocrlf(): Promise<boolean>
|
||||||
tryGetFetchUrl(): Promise<string>
|
tryGetFetchUrl(): Promise<string>
|
||||||
tryReset(): Promise<boolean>
|
tryReset(): Promise<boolean>
|
||||||
}
|
}
|
||||||
|
@ -358,6 +359,14 @@ class GitCommandManager {
|
||||||
return output.exitCode === 0
|
return output.exitCode === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async tryDisableAutocrlf(): Promise<boolean> {
|
||||||
|
const output = await this.execGit(
|
||||||
|
['config', '--local', 'core.autocrlf', 'false'],
|
||||||
|
true
|
||||||
|
)
|
||||||
|
return output.exitCode === 0
|
||||||
|
}
|
||||||
|
|
||||||
async tryGetFetchUrl(): Promise<string> {
|
async tryGetFetchUrl(): Promise<string> {
|
||||||
const output = await this.execGit(
|
const output = await this.execGit(
|
||||||
['config', '--local', '--get', 'remote.origin.url'],
|
['config', '--local', '--get', 'remote.origin.url'],
|
||||||
|
|
|
@ -96,6 +96,13 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
}
|
}
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
|
if (!settings.autocrlf) {
|
||||||
|
core.startGroup('Disabling autocrlf')
|
||||||
|
if (!(await git.tryDisableAutocrlf())) {
|
||||||
|
throw new Error("Unable to disable autocrlf")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
const authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
try {
|
try {
|
||||||
// Configure auth
|
// Configure auth
|
||||||
|
|
|
@ -73,4 +73,9 @@ export interface IGitSourceSettings {
|
||||||
* Indicates whether to persist the credentials on disk to enable scripting authenticated git commands
|
* Indicates whether to persist the credentials on disk to enable scripting authenticated git commands
|
||||||
*/
|
*/
|
||||||
persistCredentials: boolean
|
persistCredentials: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether to enable autocrlf or not when checking out a repository
|
||||||
|
*/
|
||||||
|
autocrlf: boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,5 +118,9 @@ export function getInputs(): IGitSourceSettings {
|
||||||
result.persistCredentials =
|
result.persistCredentials =
|
||||||
(core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE'
|
(core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE'
|
||||||
|
|
||||||
|
// Autocrlf
|
||||||
|
result.autocrlf = (core.getInput('autocrlf') || 'true').toUpperCase() === 'TRUE'
|
||||||
|
core.debug(`autocrlf = ${result.autocrlf}`)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue