debug: add logging to credential clearing
This commit is contained in:
parent
fea6d7077e
commit
ece24efbb4
@ -58,23 +58,39 @@ export async function configureGitAuth(
|
|||||||
try {
|
try {
|
||||||
const configOutput = await $`git config --list --show-origin`.text();
|
const configOutput = await $`git config --list --show-origin`.text();
|
||||||
const extraheaderPattern = `http.${GITHUB_SERVER_URL}/.extraheader=`;
|
const extraheaderPattern = `http.${GITHUB_SERVER_URL}/.extraheader=`;
|
||||||
|
console.log(
|
||||||
|
`Scanning git config origins for extraheader pattern: ${extraheaderPattern}`,
|
||||||
|
);
|
||||||
|
let foundExternalEntries = false;
|
||||||
for (const line of configOutput.split("\n")) {
|
for (const line of configOutput.split("\n")) {
|
||||||
if (!line.includes(extraheaderPattern)) continue;
|
if (!line.includes(extraheaderPattern)) continue;
|
||||||
// Format: "file:<path>\t<key>=<value>"
|
// Format: "file:<path>\t<key>=<value>"
|
||||||
const match = line.match(/^file:(.+?)\t/);
|
const match = line.match(/^file:(.+?)\t/);
|
||||||
if (!match) continue;
|
if (!match) {
|
||||||
|
console.log(
|
||||||
|
`Found extraheader but could not parse origin: ${line.substring(0, 80)}`,
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const configFile = match[1]!;
|
const configFile = match[1]!;
|
||||||
// Skip the local .git/config — we already handled that above
|
// Skip the local .git/config — we already handled that above
|
||||||
if (configFile.endsWith("/.git/config")) continue;
|
if (configFile.endsWith("/.git/config")) {
|
||||||
|
console.log("Skipping .git/config (already handled)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foundExternalEntries = true;
|
||||||
try {
|
try {
|
||||||
await $`git config --file ${configFile} --unset-all http.${GITHUB_SERVER_URL}/.extraheader`;
|
await $`git config --file ${configFile} --unset-all http.${GITHUB_SERVER_URL}/.extraheader`;
|
||||||
console.log(`✓ Removed authentication headers from ${configFile}`);
|
console.log(`✓ Removed authentication headers from ${configFile}`);
|
||||||
} catch {
|
} catch {
|
||||||
// Already removed or not present
|
console.log(`Could not unset extraheader from ${configFile}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
if (!foundExternalEntries) {
|
||||||
console.log("Could not enumerate git config origins");
|
console.log("No external credential config files found");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`Could not enumerate git config origins: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the remote URL to include the token for authentication
|
// Update the remote URL to include the token for authentication
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user