mirror of
https://github.com/actions/checkout.git
synced 2025-03-28 11:00:05 +01: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
|
||||
converted to HTTPS.
|
||||
default: false
|
||||
autocrlf:
|
||||
description: 'Whether to disable core.autocrlf'
|
||||
default: true
|
||||
runs:
|
||||
using: node12
|
||||
main: dist/index.js
|
||||
|
|
|
@ -44,6 +44,7 @@ export interface IGitCommandManager {
|
|||
tryClean(): Promise<boolean>
|
||||
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
|
||||
tryDisableAutomaticGarbageCollection(): Promise<boolean>
|
||||
tryDisableAutocrlf(): Promise<boolean>
|
||||
tryGetFetchUrl(): Promise<string>
|
||||
tryReset(): Promise<boolean>
|
||||
}
|
||||
|
@ -358,6 +359,14 @@ class GitCommandManager {
|
|||
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> {
|
||||
const output = await this.execGit(
|
||||
['config', '--local', '--get', 'remote.origin.url'],
|
||||
|
|
|
@ -96,6 +96,13 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
}
|
||||
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)
|
||||
try {
|
||||
// Configure auth
|
||||
|
|
|
@ -73,4 +73,9 @@ export interface IGitSourceSettings {
|
|||
* Indicates whether to persist the credentials on disk to enable scripting authenticated git commands
|
||||
*/
|
||||
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 =
|
||||
(core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE'
|
||||
|
||||
// Autocrlf
|
||||
result.autocrlf = (core.getInput('autocrlf') || 'true').toUpperCase() === 'TRUE'
|
||||
core.debug(`autocrlf = ${result.autocrlf}`)
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue