From 925b9fdcfacb09adb16bb763af122b45e656b923 Mon Sep 17 00:00:00 2001 From: Matthew Endsley <mendsley@gmail.com> Date: Fri, 28 Oct 2022 17:03:23 -0700 Subject: [PATCH] Add ability to configure core.longpaths --- README.md | 4 ++++ action.yml | 3 +++ dist/index.js | 11 +++++++++++ src/git-source-provider.ts | 12 ++++++++++++ src/git-source-settings.ts | 5 +++++ src/input-helper.ts | 3 +++ 6 files changed, 38 insertions(+) diff --git a/README.md b/README.md index 4669d76..66c2507 100644 --- a/README.md +++ b/README.md @@ -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 --> diff --git a/action.yml b/action.yml index 5133303..4500daf 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index 3dc2770..c9c90dd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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); diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 1cf9337..c4a913d 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -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( diff --git a/src/git-source-settings.ts b/src/git-source-settings.ts index 5d5b49c..bde96e8 100644 --- a/src/git-source-settings.ts +++ b/src/git-source-settings.ts @@ -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 } diff --git a/src/input-helper.ts b/src/input-helper.ts index b2916c5..c0c0b2c 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -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 }