Add ability to configure core.longpaths

This commit is contained in:
Matthew Endsley 2022-10-28 17:03:23 -07:00
parent afee87ec84
commit 925b9fdcfa
6 changed files with 38 additions and 0 deletions

View file

@ -109,6 +109,10 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
# running from unless specified. Example URLs are https://github.com or
# https://my-ghes-server.example.com
github-server-url: ''
# Enable core.longpath support
# Default: true
long-paths: ''
```
<!-- end usage -->

View file

@ -80,6 +80,9 @@ inputs:
github-server-url:
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
required: false
long-paths:
description: Enable core.longpath support
default: true
runs:
using: node16
main: dist/index.js

11
dist/index.js vendored
View file

@ -18489,6 +18489,8 @@ function getInputs() {
// Determine the GitHub URL that the repository is being hosted from
result.githubServerUrl = core.getInput('github-server-url');
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
// config
result.longpaths = core.getInput('long-paths').toUpperCase() == 'TRUE';
return result;
});
}
@ -31919,6 +31921,15 @@ function getSource(settings) {
yield git.fetch(refSpec, settings.fetchDepth);
}
core.endGroup();
if (settings.longpaths) {
core.startGroup('Setting core.longpaths to true');
yield git
.config('core.longpaths', 'true', false, false)
.catch(error => {
core.warning(`Failed to set core.longpaths with error: ${error}`);
});
core.endGroup();
}
// Checkout info
core.startGroup('Determining the checkout info');
const checkoutInfo = yield refHelper.getCheckoutInfo(git, settings.ref, settings.commit);

View file

@ -174,6 +174,18 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
}
core.endGroup()
if (settings.longpaths) {
core.startGroup('Setting core.longpaths to true')
await git
.config('core.longpaths', 'true', false, false)
.catch(error => {
core.warning(
`Failed to set core.longpaths with error: ${error}`
)
})
core.endGroup()
}
// Checkout info
core.startGroup('Determining the checkout info')
const checkoutInfo = await refHelper.getCheckoutInfo(

View file

@ -98,4 +98,9 @@ export interface IGitSourceSettings {
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
*/
githubServerUrl: string | undefined
/**
* Indicates wheter to set core.longpaths in the git config
*/
longpaths: boolean
}

View file

@ -132,5 +132,8 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.githubServerUrl = core.getInput('github-server-url')
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
// config
result.longpaths = core.getInput('long-paths').toUpperCase() == 'TRUE'
return result
}