From c5ef344f79825b7a709c35eb501cc4ffe06f0025 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Fri, 28 Oct 2022 21:15:48 -0700 Subject: [PATCH] Unset the lfs.url if one isn't specified --- dist/index.js | 39 +++++++++++++++++++++++--------------- src/git-source-provider.ts | 16 +++++++++++++--- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0bf5810..69214fd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31942,26 +31942,35 @@ function getSource(settings) { const checkoutInfo = yield refHelper.getCheckoutInfo(git, settings.ref, settings.commit); core.endGroup(); // LFS URL - if (settings.lfs && settings.lfsurl) { - core.startGroup('Setting LFS URL'); - let remote = new url_1.URL(settings.lfsurl); - remote.password = core.getInput('token'); - yield git - .config('lfs.url', remote.href, false, false) - .catch(error => { - core.info(`Failed to initialize safe directory with error: ${error}`); - }); - core.endGroup(); - if (settings.lfsCredProvider) { - core.startGroup('Setting LFS credential provider'); - let url = new url_1.URL(settings.lfsurl); - let key = 'credential.' + url.host + '.provider'; + if (settings.lfs) { + if (settings.lfsurl) { + core.startGroup('Setting LFS URL'); + let remote = new url_1.URL(settings.lfsurl); + remote.password = core.getInput('token'); yield git - .config(key, settings.lfsCredProvider, false, false) + .config('lfs.url', remote.href, false, false) .catch(error => { core.info(`Failed to initialize safe directory with error: ${error}`); }); core.endGroup(); + if (settings.lfsCredProvider) { + core.startGroup('Setting LFS credential provider'); + let url = new url_1.URL(settings.lfsurl); + let key = 'credential.' + url.host + '.provider'; + yield git + .config(key, settings.lfsCredProvider, false, false) + .catch(error => { + core.info(`Failed to initialize safe directory with error: ${error}`); + }); + core.endGroup(); + } + } + else { + yield git + .tryConfigUnset('lfs.url', false) + .catch(error => { + core.info(`Failed to remove lfs.url with error: ${error}`); + }); } } // LFS fetch diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 9c109ac..54eb6bf 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -197,10 +197,11 @@ export async function getSource(settings: IGitSourceSettings): Promise { core.endGroup() // LFS URL - if (settings.lfs && settings.lfsurl) { + if (settings.lfs) { + if (settings.lfsurl) { core.startGroup('Setting LFS URL') - let remote = new URL(settings.lfsurl) - remote.password = core.getInput('token') + let remote = new URL(settings.lfsurl) + remote.password = core.getInput('token') await git .config('lfs.url', remote.href, false, false) .catch(error => { @@ -223,6 +224,15 @@ export async function getSource(settings: IGitSourceSettings): Promise { }) core.endGroup() } + } else { + await git + .tryConfigUnset('lfs.url', false) + .catch(error => { + core.info( + `Failed to remove lfs.url with error: ${error}` + ) + }) + } } // LFS fetch