Skip to content

Commit 4f84fed

Browse files
rgeorgiev583hansu
authored andcommitted
Implement a selectMultipleBranches setting which restricts branch selection only to a single branch when disabled.
1 parent cf9df0b commit 4f84fed

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,11 @@
10951095
"default": false,
10961096
"markdownDescription": "Only follow the first parent of commits when discovering the commits to load in the Git Graph View. See [--first-parent](https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent) to find out more about this setting. This can be overridden per repository in the Git Graph View's Repository Settings Widget."
10971097
},
1098+
"git-graph.repository.selectMultipleBranches": {
1099+
"type": "boolean",
1100+
"default": true,
1101+
"description": "Enables the selection of multiple branches from the Branches dropdown."
1102+
},
10981103
"git-graph.repository.showCommitsOnlyReferencedByTags": {
10991104
"type": "boolean",
11001105
"default": true,

src/config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ class Config {
465465
return !!this.getRenamedExtensionSetting('repository.onlyFollowFirstParent', 'onlyFollowFirstParent', false);
466466
}
467467

468+
/**
469+
* Get the value of the `git-graph.repository.selectMultipleBranches` Extension Setting.
470+
*/
471+
get selectMultipleBranches() {
472+
return !!this.config.get('repository.selectMultipleBranches', true);
473+
}
474+
468475
/**
469476
* Get the value of the `git-graph.repository.showCommitsOnlyReferencedByTags` Extension Setting.
470477
*/

src/gitGraphView.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ export class GitGraphView extends Disposable {
691691
onRepoLoad: config.onRepoLoad,
692692
referenceLabels: config.referenceLabels,
693693
repoDropdownOrder: config.repoDropdownOrder,
694+
selectMultipleBranches: config.selectMultipleBranches,
694695
showRemoteBranches: config.showRemoteBranches,
695696
simplifyByDecoration: config.simplifyByDecoration,
696697
showStashes: config.showStashes,
@@ -719,14 +720,15 @@ export class GitGraphView extends Disposable {
719720
</body>`;
720721
} else if (numRepos > 0) {
721722
const stickyClassAttr = initialState.config.stickyHeader ? ' class="sticky"' : '';
723+
const branchDropdownLabel = initialState.config.selectMultipleBranches ? 'Branches' : 'Branch';
722724
let hideRemotes = '', hideSimplify = '';
723725
if (!config.toolbarButtonVisibility.remotes) { hideRemotes = 'style="display: none"'; }
724726
if (!config.toolbarButtonVisibility.simplify) { hideSimplify = 'style="display: none"'; }
725727
body = `<body>
726728
<div id="view" tabindex="-1">
727729
<div id="controls"${stickyClassAttr}>
728730
<span id="repoControl"><span class="unselectable">Repo: </span><div id="repoDropdown" class="dropdown"></div></span>
729-
<span id="branchControl"><span class="unselectable">Branches: </span><div id="branchDropdown" class="dropdown"></div></span>
731+
<span id="branchControl"><span class="unselectable">${branchDropdownLabel}: </span><div id="branchDropdown" class="dropdown"></div></span>
730732
<span id="authorControl"><span class="unselectable">Authors: </span><div id="authorDropdown" class="dropdown"></div></span>
731733
<label ${hideRemotes} id="showRemoteBranchesControl" title="Show Remote Branches"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Remotes</label>
732734
<label ${hideSimplify} id="simplifyByDecorationControl" title="Simplify By Decoration"><input type="checkbox" id="simplifyByDecorationCheckbox" tabindex="-1"><span class="customCheckbox"></span>Simplify</label>

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export interface GitGraphViewConfig {
263263
readonly onRepoLoad: OnRepoLoadConfig;
264264
readonly referenceLabels: ReferenceLabelsConfig;
265265
readonly repoDropdownOrder: RepoDropdownOrder;
266+
readonly selectMultipleBranches: boolean;
266267
readonly showRemoteBranches: boolean;
267268
readonly simplifyByDecoration: boolean;
268269
readonly showStashes: boolean;

web/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class GitGraphView {
8787
this.loadRepo(values[0]);
8888
});
8989

90-
this.branchDropdown = new Dropdown('branchDropdown', false, true, 'Branches', (values) => {
90+
this.branchDropdown = new Dropdown('branchDropdown', false, this.config.selectMultipleBranches, 'Branches', (values) => {
9191
this.currentBranches = values;
9292
this.maxCommits = this.config.initialLoadCommits;
9393
this.saveState();

0 commit comments

Comments
 (0)