debug: log to terminal
Node.js CI / CI (push) Failing after 8s
Security Scan and Upload / Security & DefectDojo Upload (push) Has been cancelled

This commit is contained in:
2026-02-04 08:06:16 -08:00
parent b6fb12ae9f
commit 6da707f1e6
3 changed files with 92 additions and 14 deletions
+43 -12
View File
@@ -237,32 +237,59 @@ const deleteStaleLocalBranch = async(
}
};
/**
* Fetches and checks out an existing remote branch.
* @param logger - The logger instance.
* @param repoPath - The repository path.
* @param branchName - The branch name to fetch and checkout.
* @returns True if successful, false if the branch no longer exists on remote.
*/
const fetchAndCheckoutRemoteBranch = async(
logger: Logger,
repoPath: string,
branchName: string,
): Promise<boolean> => {
try {
await runGitCommand(
logger,
repoPath,
`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`,
);
await runGitCommand(
logger,
repoPath,
`git checkout -b ${branchName} origin/${branchName}`,
);
return true;
} catch {
// Branch may have been deleted between check and fetch
return false;
}
};
/**
* Handles updating an existing branch with a newer version.
* @param options - The branch update options.
* @returns The update result.
* @returns The update result, or null if branch no longer exists.
*/
const handleExistingBranch = async(
options: BranchUpdateOptions,
): Promise<UpdateResult> => {
): Promise<UpdateResult | null> => {
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(
const checkedOut = await fetchAndCheckoutRemoteBranch(
logger,
repoPath,
`git fetch origin ${branchName}:refs/remotes/origin/${branchName}`,
);
await runGitCommand(
logger,
repoPath,
`git checkout -b ${branchName} origin/${branchName}`,
branchName,
);
if (!checkedOut) {
// Branch was deleted on remote, fall back to creating new branch
return null;
}
const currentVersion = await getCurrentVersionOnBranch(repoPath, packageName);
@@ -355,7 +382,11 @@ const createOrUpdateBranch = async(
const branchExists = remoteBranches.includes(`origin/${branchName}`);
if (branchExists) {
return await handleExistingBranch(options);
const result = await handleExistingBranch(options);
// If null, branch was deleted on remote between check and fetch
if (result !== null) {
return result;
}
}
return await handleNewBranch(options);
+11 -2
View File
@@ -4,8 +4,17 @@
* @author Naomi Carrigan
*/
import { Logger } from "@nhcarrigan/logger";
// import { Logger } from "@nhcarrigan/logger";
const logger = new Logger("Minori", process.env.LOG_TOKEN ?? "");
// const logger = new Logger("Minori", process.env.LOG_TOKEN ?? "");
const logger = {
error: (message: string, error: Error) => {
console.error(message, error);
},
log: (level: string, message: string) => {
console.log(level, message);
},
};
export { logger };