generated from nhcarrigan/template
fix: more branch shit
This commit is contained in:
+31
-11
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user