diff options
| author | eric sciple <ericsciple@users.noreply.github.com> | 2020-03-10 10:45:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-10 10:45:50 -0400 |
| commit | ad8315eb967265115b59c3b9dc1516f8ac5917ba (patch) | |
| tree | b1fd9b514391749e3b6809073c250686b202a961 /dist | |
| parent | 409c1e98cfd9d307759b66c12b2a69024d673ea3 (diff) | |
convert SSH URL to HTTPS (#179)
Diffstat (limited to 'dist')
| -rw-r--r-- | dist/index.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/dist/index.js b/dist/index.js index 3a29067..3082946 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5095,6 +5095,8 @@ exports.createAuthHelper = createAuthHelper; class GitAuthHelper { constructor(gitCommandManager, gitSourceSettings) { this.tokenConfigKey = `http.https://${HOSTNAME}/.extraheader`; + this.insteadOfKey = `url.https://${HOSTNAME}/.insteadOf`; + this.insteadOfValue = `git@${HOSTNAME}:`; this.temporaryHomePath = ''; this.git = gitCommandManager; this.settings = gitSourceSettings || {}; @@ -5140,11 +5142,15 @@ class GitAuthHelper { else { yield fs.promises.writeFile(newGitConfigPath, ''); } - // Configure the token try { + // Override HOME core.info(`Temporarily overriding HOME='${this.temporaryHomePath}' before making global git config changes`); this.git.setEnvironmentVariable('HOME', this.temporaryHomePath); + // Configure the token yield this.configureToken(newGitConfigPath, true); + // Configure HTTPS instead of SSH + yield this.git.tryConfigUnset(this.insteadOfKey, true); + yield this.git.config(this.insteadOfKey, this.insteadOfValue, true); } catch (err) { // Unset in case somehow written to the real global config @@ -5160,7 +5166,12 @@ class GitAuthHelper { // Configure a placeholder value. This approach avoids the credential being captured // by process creation audit events, which are commonly logged. For more information, // refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing - const output = yield this.git.submoduleForeach(`git config "${this.tokenConfigKey}" "${this.tokenPlaceholderConfigValue}" && git config --local --show-origin --name-only --get-regexp remote.origin.url`, this.settings.nestedSubmodules); + const commands = [ + `git config --local "${this.tokenConfigKey}" "${this.tokenPlaceholderConfigValue}"`, + `git config --local "${this.insteadOfKey}" "${this.insteadOfValue}"`, + `git config --local --show-origin --name-only --get-regexp remote.origin.url` + ]; + const output = yield this.git.submoduleForeach(commands.join(' && '), this.settings.nestedSubmodules); // Replace the placeholder const configPaths = output.match(/(?<=(^|\n)file:)[^\t]+(?=\tremote\.origin\.url)/g) || []; for (const configPath of configPaths) { |
