From d721580c522a3d140aaaf101289fcbc804b8168f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 05:30:23 +0000 Subject: [PATCH 1/3] Initial plan From e2f4e41a4a596a05f4021b3740e522ef5da64345 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 05:48:08 +0000 Subject: [PATCH 2/3] fix: remove double-normalization in overridePersistedExtraheader and add trailing-slash test Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/git_auth_helpers.cjs | 2 +- actions/setup/js/git_auth_helpers.test.cjs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/git_auth_helpers.cjs b/actions/setup/js/git_auth_helpers.cjs index 0067798b49e..1d2c8701efd 100644 --- a/actions/setup/js/git_auth_helpers.cjs +++ b/actions/setup/js/git_auth_helpers.cjs @@ -67,7 +67,7 @@ async function overridePersistedExtraheader(serverUrl, token) { const normalizedUrl = normalizeServerUrl(serverUrl); let previousValues; try { - previousValues = await getExtraheaderValues(normalizedUrl); + previousValues = await getExtraheaderValues(serverUrl); core.info(`git_auth_helpers: read ${previousValues.length} existing extraheader value(s) for ${normalizedUrl}`); } catch (err) { core.warning(`git_auth_helpers: could not read existing extraheader values — restoration will proceed with empty defaults: ${getErrorMessage(err)}`); diff --git a/actions/setup/js/git_auth_helpers.test.cjs b/actions/setup/js/git_auth_helpers.test.cjs index fdd5e538e06..4e97230a525 100644 --- a/actions/setup/js/git_auth_helpers.test.cjs +++ b/actions/setup/js/git_auth_helpers.test.cjs @@ -133,6 +133,16 @@ describe("git_auth_helpers.cjs", () => { expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("1 existing extraheader value(s)")); }); + + it("should strip trailing slash from server URL when reading previous values", async () => { + mockExec.getExecOutput.mockResolvedValue({ exitCode: 1, stdout: "", stderr: "" }); + + await overridePersistedExtraheader("https://github.com/", "ghp_test_token"); + + // The git config read and write must both use the normalized (no trailing slash) key + expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["config", "--get-all", EXTRAHEADER_KEY], expect.anything()); + expect(mockExec.exec).toHaveBeenCalledWith("git", ["config", "--replace-all", EXTRAHEADER_KEY, expect.any(String)]); + }); }); // ────────────────────────────────────────────────────── From 8aa45e2e70bc9f9d031183801cf155b710fb9def Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Jul 2026 05:49:01 +0000 Subject: [PATCH 3/3] test: use literal normalized key in trailing-slash overridePersistedExtraheader test Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/git_auth_helpers.test.cjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/actions/setup/js/git_auth_helpers.test.cjs b/actions/setup/js/git_auth_helpers.test.cjs index 4e97230a525..b8c5ae3e526 100644 --- a/actions/setup/js/git_auth_helpers.test.cjs +++ b/actions/setup/js/git_auth_helpers.test.cjs @@ -139,9 +139,12 @@ describe("git_auth_helpers.cjs", () => { await overridePersistedExtraheader("https://github.com/", "ghp_test_token"); - // The git config read and write must both use the normalized (no trailing slash) key - expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["config", "--get-all", EXTRAHEADER_KEY], expect.anything()); - expect(mockExec.exec).toHaveBeenCalledWith("git", ["config", "--replace-all", EXTRAHEADER_KEY, expect.any(String)]); + // "https://github.com/" (with trailing slash) must be normalized to + // "https://github.com" (without) for both the git config read and write. + // Using the literal normalized key makes the assertion explicit. + const normalizedKey = "http.https://github.com/.extraheader"; + expect(mockExec.getExecOutput).toHaveBeenCalledWith("git", ["config", "--get-all", normalizedKey], expect.anything()); + expect(mockExec.exec).toHaveBeenCalledWith("git", ["config", "--replace-all", normalizedKey, expect.any(String)]); }); });