Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simplifyByDecoration checkbox #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,11 @@
"default": true,
"description": "Show Remote Branches in Git Graph by default. This can be overridden per repository from the Git Graph View's Control Bar."
},
"git-graph.repository.simplifyByDecoration": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setting has now effect when I tested it.

"type": "boolean",
"default": false,
"description": "Show branch topology by omitting commits that are not referenced by tags. This can be overridden per repository from the Git Graph View's Control Bar."
},
"git-graph.repository.showRemoteHeads": {
"type": "boolean",
"default": true,
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ class Config {
return !!this.config.get('repository.showRemoteBranches', true);
}

/**
* Get the value of the `git-graph.repository.simplifyByDecoration` Extension Setting.
*/
get simplifyByDecoration() {
return !!this.config.get('repository.simplifyByDecoration', false);
}

/**
* Get the value of the `git-graph.repository.showRemoteHeads` Extension Setting.
*/
Expand Down
10 changes: 7 additions & 3 deletions src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ export class DataSource extends Disposable {
* @param stashes An array of all stashes in the repository.
* @returns The commits in the repository.
*/
public getCommits(repo: string, branches: ReadonlyArray<string> | null, authors: ReadonlyArray<string> | null, maxCommits: number, showTags: boolean, showRemoteBranches: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, commitOrdering: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>): Promise<GitCommitData> {
public getCommits(repo: string, branches: ReadonlyArray<string> | null, authors: ReadonlyArray<string> | null, maxCommits: number, showTags: boolean, showRemoteBranches: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, commitOrdering: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>, simplifyByDecoration: boolean): Promise<GitCommitData> {
const config = getConfig();
return Promise.all([
this.getLog(repo, branches, authors, maxCommits + 1, showTags && config.showCommitsOnlyReferencedByTags, showRemoteBranches, includeCommitsMentionedByReflogs, onlyFollowFirstParent, commitOrdering, remotes, hideRemotes, stashes),
this.getLog(repo, branches, authors, maxCommits + 1, showTags && config.showCommitsOnlyReferencedByTags, showRemoteBranches, includeCommitsMentionedByReflogs, onlyFollowFirstParent, commitOrdering, remotes, hideRemotes, stashes, simplifyByDecoration),
this.getRefs(repo, showRemoteBranches, config.showRemoteHeads, hideRemotes).then((refData: GitRefData) => refData, (errorMessage: string) => errorMessage)
]).then(async (results) => {
let commits: GitCommitRecord[] = results[0], refData: GitRefData | string = results[1], i;
Expand Down Expand Up @@ -1543,8 +1543,11 @@ export class DataSource extends Disposable {
* @param stashes An array of all stashes in the repository.
* @returns An array of commits.
*/
private getLog(repo: string, branches: ReadonlyArray<string> | null, authors: ReadonlyArray<string> | null, num: number, includeTags: boolean, includeRemotes: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, order: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>) {
private getLog(repo: string, branches: ReadonlyArray<string> | null, authors: ReadonlyArray<string> | null, num: number, includeTags: boolean, includeRemotes: boolean, includeCommitsMentionedByReflogs: boolean, onlyFollowFirstParent: boolean, order: CommitOrdering, remotes: ReadonlyArray<string>, hideRemotes: ReadonlyArray<string>, stashes: ReadonlyArray<GitStash>, simplifyByDecoration: boolean) {
const args = ['-c', 'log.showSignature=false', 'log', '--max-count=' + num, '--format=' + this.gitFormatLog, '--' + order + '-order'];
if (simplifyByDecoration) {
args.push('--simplify-by-decoration');
}
if (onlyFollowFirstParent) {
args.push('--first-parent');
}
Expand All @@ -1561,6 +1564,7 @@ export class DataSource extends Disposable {
// Show All
args.push('--branches');
if (includeTags) args.push('--tags');
else if(simplifyByDecoration) args.push('--decorate-refs-exclude=refs/tags/');
if (includeCommitsMentionedByReflogs) args.push('--reflog');
if (includeRemotes) {
if (hideRemotes.length === 0) {
Expand Down
1 change: 1 addition & 0 deletions src/extensionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const DEFAULT_REPO_STATE: GitRepoState = {
pullRequestConfig: null,
showRemoteBranches: true,
showRemoteBranchesV2: BooleanOverride.Default,
simplifyByDecoration: BooleanOverride.Default,
showStashes: BooleanOverride.Default,
showTags: BooleanOverride.Default,
workspaceFolderIndex: null
Expand Down
6 changes: 4 additions & 2 deletions src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ export class GitGraphView extends Disposable {
command: 'loadCommits',
refreshId: msg.refreshId,
onlyFollowFirstParent: msg.onlyFollowFirstParent,
...await this.dataSource.getCommits(msg.repo, msg.branches, msg.authors, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes)
...await this.dataSource.getCommits(msg.repo, msg.branches, msg.authors, msg.maxCommits, msg.showTags, msg.showRemoteBranches, msg.includeCommitsMentionedByReflogs, msg.onlyFollowFirstParent, msg.commitOrdering, msg.remotes, msg.hideRemotes, msg.stashes, msg.simplifyByDecoration)
});
break;
case 'loadConfig':
Expand Down Expand Up @@ -692,6 +692,7 @@ export class GitGraphView extends Disposable {
referenceLabels: config.referenceLabels,
repoDropdownOrder: config.repoDropdownOrder,
showRemoteBranches: config.showRemoteBranches,
simplifyByDecoration: config.simplifyByDecoration,
showStashes: config.showStashes,
showTags: config.showTags
},
Expand Down Expand Up @@ -724,7 +725,8 @@ export class GitGraphView extends Disposable {
<span id="branchControl"><span class="unselectable">Branches: </span><div id="branchDropdown" class="dropdown"></div></span>
<span id="authorControl"><span class="unselectable">Authors: </span><div id="authorDropdown" class="dropdown"></div></span>

<label id="showRemoteBranchesControl"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Show Remote Branches</label>
<label id="showRemoteBranchesControl" title="Show Remote Branches"><input type="checkbox" id="showRemoteBranchesCheckbox" tabindex="-1"><span class="customCheckbox"></span>Remotes</label>
<label id="simplifyByDecorationControl" title="Simplify By Decoration"><input type="checkbox" id="simplifyByDecorationCheckbox" tabindex="-1"><span class="customCheckbox"></span>Simplify</label>
<div id="currentBtn" title="Current"></div>
<div id="findBtn" title="Find"></div>
<div id="terminalBtn" title="Open a Terminal for this Repository"></div>
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export interface GitRepoState {
pullRequestConfig: PullRequestConfig | null;
showRemoteBranches: boolean;
showRemoteBranchesV2: BooleanOverride;
simplifyByDecoration: BooleanOverride;
showStashes: BooleanOverride;
showTags: BooleanOverride;
workspaceFolderIndex: number | null;
Expand Down Expand Up @@ -262,6 +263,7 @@ export interface GitGraphViewConfig {
readonly referenceLabels: ReferenceLabelsConfig;
readonly repoDropdownOrder: RepoDropdownOrder;
readonly showRemoteBranches: boolean;
readonly simplifyByDecoration: boolean;
readonly showStashes: boolean;
readonly showTags: boolean;
readonly stickyHeader: boolean;
Expand Down Expand Up @@ -911,6 +913,7 @@ export interface RequestLoadCommits extends RepoRequest {
readonly maxCommits: number;
readonly showTags: boolean;
readonly showRemoteBranches: boolean;
readonly simplifyByDecoration: boolean;
readonly includeCommitsMentionedByReflogs: boolean;
readonly onlyFollowFirstParent: boolean;
readonly commitOrdering: CommitOrdering;
Expand Down Expand Up @@ -942,6 +945,7 @@ export interface RequestLoadRepoInfo extends RepoRequest {
readonly command: 'loadRepoInfo';
readonly refreshId: number;
readonly showRemoteBranches: boolean;
readonly simplifyByDecoration: boolean;
readonly showStashes: boolean;
readonly hideRemotes: ReadonlyArray<string>;
}
Expand Down
16 changes: 16 additions & 0 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class GitGraphView {
private tableColHeadersElem: HTMLElement | null;
private readonly footerElem: HTMLElement;
private readonly showRemoteBranchesElem: HTMLInputElement;
private readonly simplifyByDecorationElem: HTMLInputElement;
private readonly refreshBtnElem: HTMLElement;

constructor(viewElem: HTMLElement, prevState: WebViewState | null) {
Expand Down Expand Up @@ -105,6 +106,11 @@ class GitGraphView {
this.saveRepoStateValue(this.currentRepo, 'showRemoteBranchesV2', this.showRemoteBranchesElem.checked ? GG.BooleanOverride.Enabled : GG.BooleanOverride.Disabled);
this.refresh(true);
});
this.simplifyByDecorationElem = <HTMLInputElement>document.getElementById('simplifyByDecorationCheckbox')!;
this.simplifyByDecorationElem.addEventListener('change', () => {
this.saveRepoStateValue(this.currentRepo, 'simplifyByDecoration', this.simplifyByDecorationElem.checked ? GG.BooleanOverride.Enabled : GG.BooleanOverride.Disabled);
this.refresh(true);
});

this.refreshBtnElem = document.getElementById('refreshBtn')!;
this.refreshBtnElem.addEventListener('click', () => {
Expand Down Expand Up @@ -140,6 +146,7 @@ class GitGraphView {
this.findWidget.restoreState(prevState.findWidget);
this.settingsWidget.restoreState(prevState.settingsWidget);
this.showRemoteBranchesElem.checked = getShowRemoteBranches(this.gitRepos[prevState.currentRepo].showRemoteBranchesV2);
this.simplifyByDecorationElem.checked = getSimplifyByDecoration(this.gitRepos[prevState.currentRepo].simplifyByDecoration);
}

let loadViewTo = initialState.loadViewTo;
Expand Down Expand Up @@ -224,6 +231,7 @@ class GitGraphView {
this.currentRepo = repo;
this.currentRepoLoading = true;
this.showRemoteBranchesElem.checked = getShowRemoteBranches(this.gitRepos[this.currentRepo].showRemoteBranchesV2);
this.simplifyByDecorationElem.checked = getSimplifyByDecoration(this.gitRepos[this.currentRepo].simplifyByDecoration);
this.maxCommits = this.config.initialLoadCommits;
this.gitConfig = null;
this.gitRemotes = [];
Expand Down Expand Up @@ -636,6 +644,7 @@ class GitGraphView {
repo: this.currentRepo,
refreshId: ++this.currentRepoRefreshState.loadRepoInfoRefreshId,
showRemoteBranches: getShowRemoteBranches(repoState.showRemoteBranchesV2),
simplifyByDecoration: getSimplifyByDecoration(repoState.simplifyByDecoration),
showStashes: getShowStashes(repoState.showStashes),
hideRemotes: repoState.hideRemotes
});
Expand All @@ -652,6 +661,7 @@ class GitGraphView {
maxCommits: this.maxCommits,
showTags: getShowTags(repoState.showTags),
showRemoteBranches: getShowRemoteBranches(repoState.showRemoteBranchesV2),
simplifyByDecoration: getSimplifyByDecoration(repoState.simplifyByDecoration),
includeCommitsMentionedByReflogs: getIncludeCommitsMentionedByReflogs(repoState.includeCommitsMentionedByReflogs),
onlyFollowFirstParent: getOnlyFollowFirstParent(repoState.onlyFollowFirstParent),
commitOrdering: getCommitOrdering(repoState.commitOrdering),
Expand Down Expand Up @@ -3869,6 +3879,12 @@ function getShowRemoteBranches(repoValue: GG.BooleanOverride) {
: repoValue === GG.BooleanOverride.Enabled;
}

function getSimplifyByDecoration(repoValue: GG.BooleanOverride) {
return repoValue === GG.BooleanOverride.Default
? initialState.config.simplifyByDecoration
: repoValue === GG.BooleanOverride.Enabled;
}

function getShowStashes(repoValue: GG.BooleanOverride) {
return repoValue === GG.BooleanOverride.Default
? initialState.config.showStashes
Expand Down
4 changes: 2 additions & 2 deletions web/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -805,15 +805,15 @@ body.tagLabelsRightAligned .gitRef.tag{
z-index:12;
}

#repoControl, #branchControl, #showRemoteBranchesControl{
#repoControl, #branchControl, #showRemoteBranchesControl, #simplifyByDecorationControl{
display:inline-block;
white-space:nowrap;
margin:0 10px;
}
#repoDropdown, #branchDropdown #authorDropdown{
margin-left:3px;
}
#showRemoteBranchesControl > .customCheckbox{
#showRemoteBranchesControl > .customCheckbox, #simplifyByDecorationControl > .customCheckbox{
margin-right:6px;
}

Expand Down