Skip to content

Commit 45212e1

Browse files
authored
Git - use base branch to calculate unpublished commits (microsoft#239226)
1 parent 727ebc0 commit 45212e1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

extensions/git/src/repository.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,8 +2770,25 @@ export class Repository implements Disposable {
27702770
return this.unpublishedCommits;
27712771
}
27722772

2773-
if (this.HEAD && this.HEAD.name && this.HEAD.upstream && this.HEAD.ahead && this.HEAD.ahead > 0) {
2774-
const ref1 = `${this.HEAD.upstream.remote}/${this.HEAD.upstream.name}`;
2773+
if (!this.HEAD?.name) {
2774+
this.unpublishedCommits = new Set<string>();
2775+
return this.unpublishedCommits;
2776+
}
2777+
2778+
if (this.HEAD.upstream) {
2779+
// Upstream
2780+
if (this.HEAD.ahead === 0) {
2781+
this.unpublishedCommits = new Set<string>();
2782+
} else {
2783+
const ref1 = `${this.HEAD.upstream.remote}/${this.HEAD.upstream.name}`;
2784+
const ref2 = this.HEAD.name;
2785+
2786+
const revList = await this.repository.revList(ref1, ref2);
2787+
this.unpublishedCommits = new Set<string>(revList);
2788+
}
2789+
} else if (this.historyProvider.currentHistoryItemBaseRef) {
2790+
// Base
2791+
const ref1 = this.historyProvider.currentHistoryItemBaseRef.id;
27752792
const ref2 = this.HEAD.name;
27762793

27772794
const revList = await this.repository.revList(ref1, ref2);

0 commit comments

Comments
 (0)