Skip to content

Commit

Permalink
mhutchie#361 Renamed numerous extension settings to leverage Visual S…
Browse files Browse the repository at this point in the history
…tudio Code's setting grouping.
  • Loading branch information
mhutchie committed Aug 9, 2020
1 parent f2e9c5f commit 57f52cf
Show file tree
Hide file tree
Showing 11 changed files with 2,097 additions and 1,468 deletions.
625 changes: 469 additions & 156 deletions package.json

Large diffs are not rendered by default.

320 changes: 158 additions & 162 deletions src/config.ts

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ export class DataSource implements vscode.Disposable {
this.disposables.push(askpassManager);

onDidChangeConfiguration((event) => {
if (event.affectsConfiguration('git-graph.dateType') || event.affectsConfiguration('git-graph.showSignatureStatus') || event.affectsConfiguration('git-graph.useMailmap')) {
if (
event.affectsConfiguration('git-graph.date.type') || event.affectsConfiguration('git-graph.dateType') ||
event.affectsConfiguration('git-graph.repository.commits.showSignatureStatus') || event.affectsConfiguration('git-graph.showSignatureStatus') ||
event.affectsConfiguration('git-graph.repository.useMailmap') || event.affectsConfiguration('git-graph.useMailmap')
) {
this.generateGitCommandFormats();
}
}, this.disposables);
Expand Down
31 changes: 11 additions & 20 deletions src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ExtensionState } from './extensionState';
import { Logger } from './logger';
import { RepoFileWatcher } from './repoFileWatcher';
import { RepoManager } from './repoManager';
import { ErrorInfo, GitConfigLocation, GitGraphViewInitialState, GitPushBranchMode, GitRepoSet, LoadGitGraphViewTo, RefLabelAlignment, RequestMessage, ResponseMessage, TabIconColourTheme } from './types';
import { ErrorInfo, GitConfigLocation, GitGraphViewInitialState, GitPushBranchMode, GitRepoSet, LoadGitGraphViewTo, RequestMessage, ResponseMessage, TabIconColourTheme } from './types';
import { UNABLE_TO_FIND_GIT_MSG, UNCOMMITTED, archive, copyFilePathToClipboard, copyToClipboard, createPullRequest, getNonce, getRepoName, openExtensionSettings, openFile, showErrorMessage, viewDiff, viewFileAtRevision, viewScm } from './utils';

/**
Expand Down Expand Up @@ -578,41 +578,32 @@ export class GitGraphView implements vscode.Disposable {
*/
private getHtmlForWebview() {
const config = getConfig(), nonce = getNonce();
const refLabelAlignment = config.refLabelAlignment;
const initialState: GitGraphViewInitialState = {
config: {
autoCenterCommitDetailsView: config.autoCenterCommitDetailsView,
branchLabelsAlignedToGraph: refLabelAlignment === RefLabelAlignment.BranchesAlignedToGraphAndTagsOnRight,
combineLocalAndRemoteBranchLabels: config.combineLocalAndRemoteBranchLabels,
commitDetailsViewLocation: config.commitDetailsViewLocation,
commitOrdering: config.commitOrdering,
commitDetailsView: config.commitDetailsView,
commitOrdering: config.commitOrder,
contextMenuActionsVisibility: config.contextMenuActionsVisibility,
customBranchGlobPatterns: config.customBranchGlobPatterns,
customEmojiShortcodeMappings: config.customEmojiShortcodeMappings,
customPullRequestProviders: config.customPullRequestProviders,
dateFormat: config.dateFormat,
defaultColumnVisibility: config.defaultColumnVisibility,
defaultFileViewType: config.defaultFileViewType,
dialogDefaults: config.dialogDefaults,
enhancedAccessibility: config.enhancedAccessibility,
fetchAndPrune: config.fetchAndPrune,
fetchAvatars: config.fetchAvatars && this.extensionState.isAvatarStorageAvailable(),
fileTreeCompactFolders: config.fileTreeCompactFolders,
graphColours: config.graphColours,
graphStyle: config.graphStyle,
grid: { x: 16, y: 24, offsetX: 16, offsetY: 12, expandY: 250 },
graph: config.graph,
includeCommitsMentionedByReflogs: config.includeCommitsMentionedByReflogs,
initialLoadCommits: config.initialLoadCommits,
loadMoreCommits: config.loadMoreCommits,
loadMoreCommitsAutomatically: config.loadMoreCommitsAutomatically,
muteCommitsNotAncestorsOfHead: config.muteCommitsThatAreNotAncestorsOfHead,
muteMergeCommits: config.muteMergeCommits,
mute: config.muteCommits,
onlyFollowFirstParent: config.onlyFollowFirstParent,
openRepoToHead: config.openRepoToHead,
onRepoLoadScrollToHead: config.onRepoLoadScrollToHead,
onRepoLoadShowCheckedOutBranch: config.onRepoLoadShowCheckedOutBranch,
referenceLabels: config.referenceLabels,
repoDropdownOrder: config.repoDropdownOrder,
showCurrentBranchByDefault: config.showCurrentBranchByDefault,
showTags: config.showTags,
tagLabelsOnRight: refLabelAlignment !== RefLabelAlignment.Normal
showTags: config.showTags
},
lastActiveRepo: this.extensionState.getLastActiveRepo(),
loadViewTo: this.loadViewTo,
Expand All @@ -623,8 +614,8 @@ export class GitGraphView implements vscode.Disposable {
const globalState = this.extensionState.getGlobalViewState();

let body, numRepos = Object.keys(initialState.repos).length, colorVars = '', colorParams = '';
for (let i = 0; i < initialState.config.graphColours.length; i++) {
colorVars += '--git-graph-color' + i + ':' + initialState.config.graphColours[i] + '; ';
for (let i = 0; i < initialState.config.graph.colours.length; i++) {
colorVars += '--git-graph-color' + i + ':' + initialState.config.graph.colours[i] + '; ';
colorParams += '[data-color="' + i + '"]{--git-graph-color:var(--git-graph-color' + i + ');} ';
}

Expand Down
52 changes: 34 additions & 18 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,53 +205,69 @@ export interface GitGraphViewInitialState {
}

export interface GitGraphViewConfig {
readonly autoCenterCommitDetailsView: boolean;
readonly branchLabelsAlignedToGraph: boolean;
readonly combineLocalAndRemoteBranchLabels: boolean;
readonly commitDetailsViewLocation: CommitDetailsViewLocation;
readonly commitDetailsView: CommitDetailsViewConfig;
readonly commitOrdering: CommitOrdering;
readonly contextMenuActionsVisibility: ContextMenuActionsVisibility;
readonly customBranchGlobPatterns: ReadonlyArray<CustomBranchGlobPattern>;
readonly customEmojiShortcodeMappings: ReadonlyArray<CustomEmojiShortcodeMapping>;
readonly customPullRequestProviders: ReadonlyArray<CustomPullRequestProvider>;
readonly dateFormat: DateFormat;
readonly defaultColumnVisibility: DefaultColumnVisibility;
readonly defaultFileViewType: FileViewType;
readonly dialogDefaults: DialogDefaults;
readonly enhancedAccessibility: boolean;
readonly fetchAndPrune: boolean;
readonly fetchAvatars: boolean;
readonly fileTreeCompactFolders: boolean;
readonly graphColours: ReadonlyArray<string>;
readonly graphStyle: GraphStyle;
readonly grid: { x: number, y: number, offsetX: number, offsetY: number, expandY: number };
readonly graph: GraphConfig;
readonly includeCommitsMentionedByReflogs: boolean;
readonly initialLoadCommits: number;
readonly loadMoreCommits: number;
readonly loadMoreCommitsAutomatically: boolean;
readonly muteCommitsNotAncestorsOfHead: boolean;
readonly muteMergeCommits: boolean;
readonly mute: MuteCommitsConfig;
readonly onlyFollowFirstParent: boolean;
readonly openRepoToHead: boolean;
readonly onRepoLoadScrollToHead: boolean;
readonly onRepoLoadShowCheckedOutBranch: boolean;
readonly referenceLabels: ReferenceLabelsConfig;
readonly repoDropdownOrder: RepoDropdownOrder;
readonly showCurrentBranchByDefault: boolean;
readonly showTags: boolean;
readonly tagLabelsOnRight: boolean;
}

export interface GitGraphViewGlobalState {
alwaysAcceptCheckoutCommit: boolean;
issueLinkingConfig: IssueLinkingConfig | null;
}

export interface CommitDetailsViewConfig {
readonly autoCenter: boolean;
readonly fileTreeCompactFolders: boolean;
readonly fileViewType: FileViewType;
readonly location: CommitDetailsViewLocation;
}

export interface GraphConfig {
readonly colours: ReadonlyArray<string>;
readonly style: GraphStyle;
readonly grid: { x: number, y: number, offsetX: number, offsetY: number, expandY: number };
}

export type LoadGitGraphViewTo = {
repo: string,
commitDetails: {
commitHash: string,
compareWithHash: string | null
readonly repo: string,
readonly commitDetails: {
readonly commitHash: string,
readonly compareWithHash: string | null
} | null
} | null;

export interface MuteCommitsConfig {
readonly commitsNotAncestorsOfHead: boolean;
readonly mergeCommits: boolean;
}

export interface ReferenceLabelsConfig {
readonly branchLabelsAlignedToGraph: boolean;
readonly combineLocalAndRemoteBranchLabels: boolean;
readonly tagLabelsOnRight: boolean;
}


/* Extension Settings Types */

Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export function openFile(repo: string, filePath: string) {
if (err === null) {
vscode.commands.executeCommand('vscode.open', vscode.Uri.file(p), {
preview: true,
viewColumn: getConfig().openDiffTabLocation
viewColumn: getConfig().openNewTabEditorGroup
}).then(
() => resolve(null),
() => resolve('Visual Studio Code was unable to open ' + filePath + '.')
Expand Down Expand Up @@ -334,7 +334,7 @@ export function viewDiff(repo: string, fromHash: string, toHash: string, oldFile

return vscode.commands.executeCommand('vscode.diff', encodeDiffDocUri(repo, oldFilePath, fromHash === toHash ? fromHash + '^' : fromHash, type, DiffSide.Old), encodeDiffDocUri(repo, newFilePath, toHash, type, DiffSide.New), title, {
preview: true,
viewColumn: getConfig().openDiffTabLocation
viewColumn: getConfig().openNewTabEditorGroup
}).then(
() => null,
() => 'Visual Studio Code was unable load the diff editor for ' + newFilePath + '.'
Expand All @@ -350,7 +350,7 @@ export async function viewFileAtRevision(repo: string, hash: string, filePath: s

return vscode.commands.executeCommand('vscode.open', encodeDiffDocUri(repo, filePath, hash, GitFileStatus.Modified, DiffSide.New).with({ path: title }), {
preview: true,
viewColumn: getConfig().openDiffTabLocation
viewColumn: getConfig().openNewTabEditorGroup
}).then(
() => null,
() => 'Visual Studio Code was unable to open ' + filePath + ' at commit ' + abbrevCommit(hash) + '.'
Expand Down
Loading

0 comments on commit 57f52cf

Please sign in to comment.