Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class GitGraphView {
// Filter any branches that are currently selected, but no longer exist
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
this.currentBranches = this.currentBranches.filter((branch) =>
this.gitBranches.includes(branch) || globPatterns.includes(branch)
branch === HEAD_BRANCH || this.gitBranches.includes(branch) || globPatterns.includes(branch)
);
}
if (this.currentBranches === null || this.currentBranches.length === 0) {
Expand Down Expand Up @@ -529,6 +529,9 @@ class GitGraphView {
if (includeShowAll) {
options.push({ name: 'Show All', value: SHOW_ALL_BRANCHES });
}
if (this.gitBranchHead !== null) {
options.push({ name: 'HEAD (' + this.gitBranchHead + ')', value: HEAD_BRANCH });
}
for (let i = 0; i < this.config.customBranchGlobPatterns.length; i++) {
options.push({ name: 'Glob: ' + this.config.customBranchGlobPatterns[i].name, value: this.config.customBranchGlobPatterns[i].glob });
}
Expand All @@ -538,6 +541,15 @@ class GitGraphView {
return options;
}

private resolveHeadBranches(): string[] {
return this.currentBranches!.map((branch) => {
if (branch === HEAD_BRANCH && this.gitBranchHead !== null) {
return this.gitBranchHead;
}
return branch;
});
}

public getCommitId(hash: string) {
return typeof this.commitLookup[hash] === 'number' ? this.commitLookup[hash] : null;
}
Expand Down Expand Up @@ -608,7 +620,7 @@ class GitGraphView {
command: 'loadCommits',
repo: this.currentRepo,
refreshId: ++this.currentRepoRefreshState.loadCommitsRefreshId,
branches: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.currentBranches,
branches: this.currentBranches === null || (this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES) ? null : this.resolveHeadBranches(),
maxCommits: this.maxCommits,
showTags: getShowTags(repoState.showTags),
showRemoteBranches: getShowRemoteBranches(repoState.showRemoteBranchesV2),
Expand Down
1 change: 1 addition & 0 deletions web/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const ELLIPSIS = '&#8230;';
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
const UNCOMMITTED = '*';
const SHOW_ALL_BRANCHES = '';
const HEAD_BRANCH = 'HEAD';

const COLUMN_HIDDEN = -100;
const COLUMN_AUTO = -101;
Expand Down