fix: more branch shit
Node.js CI / CI (push) Has been cancelled
Security Scan and Upload / Security & DefectDojo Upload (push) Has been cancelled

This commit is contained in:
2026-02-03 19:34:10 -08:00
parent 4a8973a6e8
commit d0bf95cb6d
+31 -11
View File
@@ -213,18 +213,16 @@ const cloneRepository = async(
}; };
/** /**
* Handles updating an existing branch with a newer version. * Deletes a stale local branch if it exists.
* @param options - The branch update options. * @param logger - The logger instance.
* @returns The update result. * @param repoPath - Path to the repository.
* @param branchName - Name of the branch to delete.
*/ */
const handleExistingBranch = async( const deleteStaleLocalBranch = async(
options: BranchUpdateOptions, logger: Logger,
): Promise<UpdateResult> => { repoPath: string,
const { branchName, clonedRepo, logger, packageName, targetVersion } branchName: string,
= options; ): Promise<void> => {
const { path: repoPath } = clonedRepo;
// Delete local branch if it exists (stale from previous run)
const localBranchOutput = await runGitCommand(logger, repoPath, "git branch"); const localBranchOutput = await runGitCommand(logger, repoPath, "git branch");
const localBranchNames = localBranchOutput. const localBranchNames = localBranchOutput.
split("\n"). split("\n").
@@ -237,6 +235,28 @@ const handleExistingBranch = async(
if (localBranchNames.includes(branchName)) { if (localBranchNames.includes(branchName)) {
await runGitCommand(logger, repoPath, `git branch -D ${branchName}`); await runGitCommand(logger, repoPath, `git branch -D ${branchName}`);
} }
};
/**
* Handles updating an existing branch with a newer version.
* @param options - The branch update options.
* @returns The update result.
*/
const handleExistingBranch = async(
options: BranchUpdateOptions,
): Promise<UpdateResult> => {
const { branchName, clonedRepo, logger, packageName, targetVersion }
= options;
const { path: repoPath } = clonedRepo;
await deleteStaleLocalBranch(logger, repoPath, branchName);
// Fetch the specific branch to ensure we have the latest refs
await runGitCommand(
logger,
repoPath,
`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`,
);
await runGitCommand( await runGitCommand(
logger, logger,