Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/setup/js/git_auth_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
Expand Down
13 changes: 13 additions & 0 deletions actions/setup/js/git_auth_helpers.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ 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 () => {
Comment thread
pelikhan marked this conversation as resolved.
mockExec.getExecOutput.mockResolvedValue({ exitCode: 1, stdout: "", stderr: "" });

await overridePersistedExtraheader("https://github.com/", "ghp_test_token");

// "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)]);
Comment thread
pelikhan marked this conversation as resolved.
});
});

// ──────────────────────────────────────────────────────
Expand Down
Loading