Skip to content

Commit 6bba64e

Browse files
Copilotalexr00
andcommitted
Address code review: fix null check, comment accuracy, and remove unnecessary upstream setting
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 97ccc62 commit 6bba64e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/github/folderRepositoryManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ export class FolderRepositoryManager extends Disposable {
24952495
// Check if the branch has diverged (ahead > 0 && behind > 0)
24962496
if (branch.ahead !== undefined && branch.ahead > 0 && branch.behind !== undefined && branch.behind > 0) {
24972497
// Use merge-base analysis to distinguish between force-push and normal divergence
2498-
// If remote was force-pushed, the merge-base will be at or near the current HEAD
2498+
// If remote was force-pushed, the merge-base will equal the current HEAD
24992499
// If it's normal divergence, the merge-base will be older than both HEAD and remote
25002500
let isForcePush = false;
25012501

@@ -2506,7 +2506,7 @@ export class FolderRepositoryManager extends Disposable {
25062506

25072507
// If merge-base equals the current HEAD commit, it means the remote history
25082508
// was rewritten (force-push/rebase), and local commits don't exist in remote
2509-
if (mergeBase === branch.commit) {
2509+
if (mergeBase && mergeBase === branch.commit) {
25102510
isForcePush = true;
25112511
}
25122512
} catch (e) {
@@ -2549,6 +2549,7 @@ export class FolderRepositoryManager extends Disposable {
25492549
const currentBranchName = branch.name;
25502550

25512551
// Create a temp branch at the remote commit with uniqueness guarantee
2552+
const MAX_BRANCH_NAME_ATTEMPTS = 10;
25522553
let tempCounter = 0;
25532554
do {
25542555
tempBranchName = `temp-pr-update-${Date.now()}-${Math.random().toString(36).substring(7)}${tempCounter > 0 ? `-${tempCounter}` : ''}`;
@@ -2561,14 +2562,13 @@ export class FolderRepositoryManager extends Disposable {
25612562
// Branch doesn't exist, we can use this name
25622563
break;
25632564
}
2564-
} while (tempCounter < 10); // Safety limit
2565+
} while (tempCounter < MAX_BRANCH_NAME_ATTEMPTS);
25652566

25662567
if (!tempBranchName) {
25672568
throw new Error('Could not generate unique temporary branch name');
25682569
}
25692570

25702571
await this._repository.createBranch(tempBranchName, false, remoteBranch.commit);
2571-
await this._repository.setBranchUpstream(tempBranchName, remoteBranchRef);
25722572

25732573
// Checkout the temp branch
25742574
await this._repository.checkout(tempBranchName);

0 commit comments

Comments
 (0)