remove unnecessary git cleanup logic
This commit is contained in:
@@ -20,7 +20,7 @@ import {
|
|||||||
revokeInstallationToken,
|
revokeInstallationToken,
|
||||||
setupGitHubInstallationToken,
|
setupGitHubInstallationToken,
|
||||||
} from "./utils/github.ts";
|
} from "./utils/github.ts";
|
||||||
import { restoreGitConfig, setupGitAuth, setupGitBranch, setupGitConfig } from "./utils/setup.ts";
|
import { setupGitAuth, setupGitBranch, setupGitConfig } from "./utils/setup.ts";
|
||||||
|
|
||||||
// runtime validation using agents (needed for ArkType)
|
// runtime validation using agents (needed for ArkType)
|
||||||
// Note: The AgentName type is defined in external.ts, this is the runtime validator
|
// Note: The AgentName type is defined in external.ts, this is the runtime validator
|
||||||
@@ -96,8 +96,6 @@ export async function main(inputs: Inputs): Promise<MainResult> {
|
|||||||
error: errorMessage,
|
error: errorMessage,
|
||||||
};
|
};
|
||||||
} finally {
|
} finally {
|
||||||
restoreGitConfig();
|
|
||||||
|
|
||||||
if (pollInterval) {
|
if (pollInterval) {
|
||||||
clearInterval(pollInterval);
|
clearInterval(pollInterval);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import { log } from "./cli.ts";
|
|||||||
import type { RepoContext } from "./github.ts";
|
import type { RepoContext } from "./github.ts";
|
||||||
import { $ } from "./shell.ts";
|
import { $ } from "./shell.ts";
|
||||||
|
|
||||||
// Store original remote URL for cleanup (only thing we need to restore)
|
|
||||||
let originalRemoteUrl: string | null = null;
|
|
||||||
|
|
||||||
export interface SetupOptions {
|
export interface SetupOptions {
|
||||||
tempDir: string;
|
tempDir: string;
|
||||||
repoUrl?: string;
|
repoUrl?: string;
|
||||||
@@ -78,18 +75,6 @@ export function setupGitConfig(): void {
|
|||||||
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
|
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
|
||||||
const repoDir = process.cwd();
|
const repoDir = process.cwd();
|
||||||
|
|
||||||
// Store original remote URL for cleanup
|
|
||||||
try {
|
|
||||||
originalRemoteUrl =
|
|
||||||
execSync("git config --local --get remote.origin.url", {
|
|
||||||
cwd: repoDir,
|
|
||||||
stdio: "pipe",
|
|
||||||
encoding: "utf-8",
|
|
||||||
}).trim() || null;
|
|
||||||
} catch {
|
|
||||||
originalRemoteUrl = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("🔐 Setting up git authentication...");
|
log.info("🔐 Setting up git authentication...");
|
||||||
|
|
||||||
// Remove existing git auth headers that actions/checkout might have set
|
// Remove existing git auth headers that actions/checkout might have set
|
||||||
@@ -150,61 +135,3 @@ export function setupGitBranch(payload: Payload): void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up local git configuration after action completes
|
|
||||||
* Removes the --local config entries we added so the repo returns to its original state
|
|
||||||
* Only runs in local development (not in GitHub Actions)
|
|
||||||
*/
|
|
||||||
export function restoreGitConfig(): void {
|
|
||||||
if (process.env.GITHUB_ACTIONS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const repoDir = process.cwd();
|
|
||||||
log.info("🔄 Cleaning up git configuration...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
execSync("git config --local --unset user.email", {
|
|
||||||
cwd: repoDir,
|
|
||||||
stdio: "pipe",
|
|
||||||
});
|
|
||||||
log.debug("✓ Removed local user.email");
|
|
||||||
} catch {
|
|
||||||
// Ignore if unset fails (config might not exist)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
execSync("git config --local --unset user.name", {
|
|
||||||
cwd: repoDir,
|
|
||||||
stdio: "pipe",
|
|
||||||
});
|
|
||||||
log.debug("✓ Removed local user.name");
|
|
||||||
} catch {
|
|
||||||
// Ignore if unset fails (config might not exist)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore original remote URL if we stored it
|
|
||||||
if (originalRemoteUrl !== null) {
|
|
||||||
try {
|
|
||||||
$("git", ["remote", "set-url", "origin", originalRemoteUrl], { cwd: repoDir });
|
|
||||||
log.debug("✓ Restored original remote URL");
|
|
||||||
} catch (error) {
|
|
||||||
log.warning(
|
|
||||||
`Failed to restore remote URL: ${error instanceof Error ? error.message : String(error)}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("✓ Git configuration cleanup completed");
|
|
||||||
} catch (error) {
|
|
||||||
// Log warning but don't fail - this is cleanup
|
|
||||||
log.warning(
|
|
||||||
`Failed to clean up git config: ${error instanceof Error ? error.message : String(error)}`
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
// Clear stored remote URL
|
|
||||||
originalRemoteUrl = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user