From aba21e75831d1356025554918dd3d9e0c245e422 Mon Sep 17 00:00:00 2001 From: David Blass Date: Tue, 25 Nov 2025 16:05:40 -0500 Subject: [PATCH] remove unnecessary git cleanup logic --- main.ts | 4 +-- utils/setup.ts | 73 -------------------------------------------------- 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/main.ts b/main.ts index 17e23d4..b3e3c87 100644 --- a/main.ts +++ b/main.ts @@ -20,7 +20,7 @@ import { revokeInstallationToken, setupGitHubInstallationToken, } 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) // 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 { error: errorMessage, }; } finally { - restoreGitConfig(); - if (pollInterval) { clearInterval(pollInterval); } diff --git a/utils/setup.ts b/utils/setup.ts index a684706..843a5c6 100644 --- a/utils/setup.ts +++ b/utils/setup.ts @@ -5,9 +5,6 @@ import { log } from "./cli.ts"; import type { RepoContext } from "./github.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 { tempDir: string; repoUrl?: string; @@ -78,18 +75,6 @@ export function setupGitConfig(): void { export function setupGitAuth(githubToken: string, repoContext: RepoContext): void { 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..."); // 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; - } -}