Skip to content

Commit 8e07bb7

Browse files
authored
Merge pull request #33 from ipcjs/feat-head
feat: add `HEAD` in branch options
2 parents ea434f8 + c69f654 commit 8e07bb7

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,14 @@
88
"task.problemMatchers.neverPrompt": {
99
"npm": true
1010
},
11+
"[typescript]": {
12+
"editor.formatOnSave": true,
13+
},
14+
"[javascript]": {
15+
"editor.formatOnSave": true,
16+
},
17+
"[jsonc]": {
18+
"editor.formatOnSave": true,
19+
},
1120
"typescript.tsdk": "./node_modules/typescript/lib"
1221
}

src/dataSource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as vscode from 'vscode';
66
import { AskpassEnvironment, AskpassManager } from './askpass/askpassManager';
77
import { getConfig } from './config';
88
import { Logger } from './logger';
9-
import {ActionedUser, CommitOrdering, DateType, DeepWriteable, ErrorInfo, ErrorInfoExtensionPrefix, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPushBranchMode, GitRepoConfig, GitRepoConfigBranches, GitResetMode, GitSignature, GitSignatureStatus, GitStash, GitTagDetails, MergeActionOn, RebaseActionOn, SquashMessageFormat, TagType, Writeable } from './types';
9+
import { ActionedUser, CommitOrdering, DateType, DeepWriteable, ErrorInfo, ErrorInfoExtensionPrefix, GitCommit, GitCommitDetails, GitCommitStash, GitConfigLocation, GitFileChange, GitFileStatus, GitPushBranchMode, GitRepoConfig, GitRepoConfigBranches, GitResetMode, GitSignature, GitSignatureStatus, GitStash, GitTagDetails, MergeActionOn, RebaseActionOn, SquashMessageFormat, TagType, Writeable } from './types';
1010
import { GitExecutable, GitVersionRequirement, UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, abbrevCommit, constructIncompatibleGitVersionMessage, doesVersionMeetRequirement, getPathFromStr, getPathFromUri, openGitTerminal, pathWithTrailingSlash, realpath, resolveSpawnOutput, showErrorMessage } from './utils';
1111
import { Disposable } from './utils/disposable';
1212
import { Event } from './utils/event';
@@ -308,7 +308,7 @@ export class DataSource extends Disposable {
308308
return {
309309
config: {
310310
branches: branches,
311-
authors,
311+
authors,
312312
diffTool: getConfigValue(consolidatedConfigs, GitConfigKey.DiffTool),
313313
guiDiffTool: getConfigValue(consolidatedConfigs, GitConfigKey.DiffGuiTool),
314314
pushDefault: getConfigValue(consolidatedConfigs, GitConfigKey.RemotePushDefault),
@@ -1548,7 +1548,7 @@ export class DataSource extends Disposable {
15481548
if (onlyFollowFirstParent) {
15491549
args.push('--first-parent');
15501550
}
1551-
if(authors !== null) {
1551+
if (authors !== null) {
15521552
for (let i = 0; i < authors.length; i++) {
15531553
args.push(`--author=${authors[i]} <`);
15541554
}

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ export interface GitRepoConfig {
107107
}
108108

109109
export type GitRepoConfigBranches = { [branchName: string]: GitRepoConfigBranch };
110-
export interface ActionedUser{
111-
name: string;
112-
email: string;
110+
export interface ActionedUser {
111+
name: string;
112+
email: string;
113113
};
114114
export interface GitRepoConfigBranch {
115115
readonly pushRemote: string | null;

web/dropdown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ class Dropdown {
9494
* @param options An array of the options to display in the dropdown.
9595
* @param optionsSelected An array of the selected options in the dropdown.
9696
*/
97-
public setOptions(options: ReadonlyArray<DropdownOption>, optionsSelected: string[]|null) {
97+
public setOptions(options: ReadonlyArray<DropdownOption>, optionsSelected: string[] | null) {
9898
this.options = options;
9999
this.optionsSelected = [];
100100
let selectedOption = -1, isSelected;
101-
if(optionsSelected) {
101+
if (optionsSelected) {
102102
for (let i = 0; i < options.length; i++) {
103103
isSelected = optionsSelected.includes(options[i].value);
104104
this.optionsSelected[i] = isSelected;

web/main.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,18 @@ class GitGraphView {
256256
// Update the state of the fetch button
257257
this.renderFetchButton();
258258

259-
// Configure current branches
260-
if (this.currentBranches !== null && !(this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES)) {
261-
// Filter any branches that are currently selected, but no longer exist
262-
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
263-
this.currentBranches = this.currentBranches.filter((branch) =>
264-
this.gitBranches.includes(branch) || globPatterns.includes(branch)
265-
);
266-
}
259+
const filterCurrentBranches = () => {
260+
// Configure current branches
261+
if (this.currentBranches !== null && !(this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES)) {
262+
// Filter any branches that are currently selected, but no longer exist
263+
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
264+
this.currentBranches = this.currentBranches.filter((branch) =>
265+
this.gitBranches.includes(branch) || globPatterns.includes(branch) || branch === 'HEAD'
266+
);
267+
}
268+
};
269+
270+
filterCurrentBranches();
267271
if (this.currentBranches === null || this.currentBranches.length === 0) {
268272
// No branches are currently selected
269273
const onRepoLoadShowCheckedOutBranch = getOnRepoLoadShowCheckedOutBranch(this.gitRepos[this.currentRepo].onRepoLoadShowCheckedOutBranch);
@@ -284,15 +288,8 @@ class GitGraphView {
284288
this.currentBranches.push(SHOW_ALL_BRANCHES);
285289
}
286290
}
291+
filterCurrentBranches();
287292

288-
// Configure current branches
289-
if (this.currentBranches !== null && !(this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES)) {
290-
// Filter any branches that are currently selected, but no longer exist
291-
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
292-
this.currentBranches = this.currentBranches.filter((branch) =>
293-
this.gitBranches.includes(branch) || globPatterns.includes(branch)
294-
);
295-
}
296293
this.saveState();
297294
this.currentAuthors = [];
298295
this.currentAuthors.push(SHOW_ALL_BRANCHES);
@@ -558,6 +555,7 @@ class GitGraphView {
558555
if (includeShowAll) {
559556
options.push({ name: 'Show All', value: SHOW_ALL_BRANCHES });
560557
}
558+
options.push({ name: 'HEAD', value: 'HEAD' });
561559
for (let i = 0; i < this.config.customBranchGlobPatterns.length; i++) {
562560
options.push({ name: 'Glob: ' + this.config.customBranchGlobPatterns[i].name, value: this.config.customBranchGlobPatterns[i].glob });
563561
}
@@ -569,7 +567,7 @@ class GitGraphView {
569567
public getAuthorOptions(): ReadonlyArray<DialogSelectInputOption> {
570568
const options: DialogSelectInputOption[] = [];
571569
options.push({ name: 'All', value: SHOW_ALL_BRANCHES });
572-
if(this.gitConfig && this.gitConfig.authors) {
570+
if (this.gitConfig && this.gitConfig.authors) {
573571
for (let i = 0; i < this!.gitConfig!.authors.length; i++) {
574572
const author = this!.gitConfig!.authors[i];
575573
options.push({ name: author.name, value: author.name });
@@ -915,8 +913,8 @@ class GitGraphView {
915913

916914

917915
}
918-
function getResizeColHtml(col:number) {
919-
return (col > 0 ? '<span class="resizeCol left" data-col="' + (col - 1) + '"></span>' : '') + (col < 4 ? '<span class="resizeCol right" data-col="' + col + '"></span>' : '');
916+
function getResizeColHtml(col: number) {
917+
return (col > 0 ? '<span class="resizeCol left" data-col="' + (col - 1) + '"></span>' : '') + (col < 4 ? '<span class="resizeCol right" data-col="' + col + '"></span>' : '');
920918
}
921919
this.tableElem.innerHTML = '<table>' + html + '</table>';
922920
this.footerElem.innerHTML = this.moreCommitsAvailable ? '<div id="loadMoreCommitsBtn" class="roundedBtn">Load More Commits</div>' : '';
@@ -2942,20 +2940,20 @@ class GitGraphView {
29422940
this.renderCdvFileViewTypeBtns();
29432941
}
29442942

2945-
private openFolders(open:boolean) {
2943+
private openFolders(open: boolean) {
29462944
let expandedCommit = this.expandedCommit;
29472945
if (expandedCommit === null || expandedCommit.fileTree === null) return;
29482946
let folders = document.getElementsByClassName('fileTreeFolder');
29492947
for (let i = 0; i < folders.length; i++) {
29502948
let sourceElem = <HTMLElement>(folders[i]);
29512949
let parent = sourceElem.parentElement!;
2952-
if(open) {
2950+
if (open) {
29532951
parent.classList.remove('closed');
29542952
sourceElem.children[0].children[0].innerHTML = SVG_ICONS.openFolder;
29552953
parent.children[1].classList.remove('hidden');
29562954
alterFileTreeFolderOpen(expandedCommit.fileTree, decodeURIComponent(sourceElem.dataset.folderpath!), true);
29572955

2958-
} else{
2956+
} else {
29592957
parent.classList.add('closed');
29602958
sourceElem.children[0].children[0].innerHTML = SVG_ICONS.closedFolder;
29612959
parent.children[1].classList.add('hidden');
@@ -3210,7 +3208,7 @@ class GitGraphView {
32103208
function setFolderBtns() {
32113209
let btns = document.getElementsByClassName('cdvFolderBtn');
32123210
for (let i = 0; i < btns.length; i++) {
3213-
if(listView)
3211+
if (listView)
32143212
btns[i].classList.add('hidden');
32153213
else
32163214
btns[i].classList.remove('hidden');

0 commit comments

Comments
 (0)