Procházet zdrojové kódy

Removes config from container

Reworks all usages to use configuration.get
main
Eric Amodio před 2 roky
rodič
revize
c8e878af54
50 změnil soubory, kde provedl 275 přidání a 270 odebrání
  1. +6
    -16
      src/annotations/annotations.ts
  2. +10
    -11
      src/annotations/blameAnnotationProvider.ts
  3. +23
    -20
      src/annotations/fileAnnotationController.ts
  4. +5
    -5
      src/annotations/gutterBlameAnnotationProvider.ts
  5. +4
    -5
      src/annotations/gutterChangesAnnotationProvider.ts
  6. +1
    -1
      src/annotations/gutterHeatmapBlameAnnotationProvider.ts
  7. +3
    -3
      src/annotations/lineAnnotationController.ts
  8. +2
    -4
      src/api/actionRunners.ts
  9. +2
    -1
      src/avatars.ts
  10. +7
    -12
      src/codelens/codeLensController.ts
  11. +6
    -6
      src/codelens/codeLensProvider.ts
  12. +2
    -1
      src/commands/copyShaToClipboard.ts
  13. +2
    -1
      src/commands/externalDiff.ts
  14. +2
    -1
      src/commands/git/search.ts
  15. +2
    -1
      src/commands/gitCommands.utils.ts
  16. +2
    -1
      src/commands/quickCommand.ts
  17. +2
    -1
      src/commands/searchCommits.ts
  18. +6
    -8
      src/commands/switchMode.ts
  19. +0
    -10
      src/container.ts
  20. +57
    -55
      src/env/node/git/localGitProvider.ts
  21. +2
    -1
      src/env/node/providers.ts
  22. +4
    -4
      src/extension.ts
  23. +12
    -12
      src/git/formatters/commitFormatter.ts
  24. +1
    -1
      src/git/gitProviderService.ts
  25. +2
    -2
      src/git/models/reference.ts
  26. +16
    -6
      src/git/models/repository.ts
  27. +6
    -4
      src/hovers/hovers.ts
  28. +15
    -10
      src/hovers/lineHoverController.ts
  29. +4
    -4
      src/plus/github/githubGitProvider.ts
  30. +2
    -2
      src/plus/webviews/timeline/timelineWebview.ts
  31. +2
    -2
      src/plus/webviews/timeline/timelineWebviewView.ts
  32. +10
    -13
      src/statusbar/statusBarController.ts
  33. +2
    -1
      src/trackers/gitLineTracker.ts
  34. +1
    -1
      src/views/contributorsView.ts
  35. +5
    -5
      src/views/nodes/commitNode.ts
  36. +3
    -3
      src/views/nodes/common.ts
  37. +3
    -2
      src/views/nodes/contributorNode.ts
  38. +3
    -2
      src/views/nodes/contributorsNode.ts
  39. +5
    -4
      src/views/nodes/fileRevisionAsCommitNode.ts
  40. +3
    -2
      src/views/nodes/mergeConflictCurrentChangesNode.ts
  41. +3
    -2
      src/views/nodes/mergeConflictIncomingChangesNode.ts
  42. +2
    -2
      src/views/nodes/rebaseStatusNode.ts
  43. +2
    -3
      src/views/nodes/resultsCommitsNode.ts
  44. +4
    -3
      src/views/nodes/stashNode.ts
  45. +3
    -3
      src/views/repositoriesView.ts
  46. +4
    -4
      src/views/viewBase.ts
  47. +2
    -1
      src/vsls/vsls.ts
  48. +4
    -4
      src/webviews/rebase/rebaseEditor.ts
  49. +3
    -3
      src/webviews/webviewWithConfigBase.ts
  50. +3
    -1
      src/webviews/welcome/welcomeWebview.ts

+ 6
- 16
src/annotations/annotations.ts Zobrazit soubor

@ -13,7 +13,6 @@ import {
import { HeatmapLocations } from '../config';
import { Config, configuration } from '../configuration';
import { Colors, GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
import { GitCommit } from '../git/models';
import { getWidth, interpolate, pad } from '../system/string';
@ -62,19 +61,14 @@ const defaultHeatmapColors = [
let heatmapColors: { hot: string[]; cold: string[] } | undefined;
export async function getHeatmapColors() {
if (heatmapColors == null) {
const { coldColor, hotColor } = configuration.get('heatmap');
let colors;
if (
Container.instance.config.heatmap.coldColor === defaultHeatmapColdColor &&
Container.instance.config.heatmap.hotColor === defaultHeatmapHotColor
) {
if (coldColor === defaultHeatmapColdColor && hotColor === defaultHeatmapHotColor) {
colors = defaultHeatmapColors;
} else {
const chroma = (await import(/* webpackChunkName: "heatmap-chroma" */ 'chroma-js')).default;
colors = chroma
.scale([Container.instance.config.heatmap.hotColor, Container.instance.config.heatmap.coldColor])
.mode('lrgb')
.classes(20)
.colors(20);
colors = chroma.scale([hotColor, coldColor]).mode('lrgb').classes(20).colors(20);
}
heatmapColors = {
@ -83,11 +77,7 @@ export async function getHeatmapColors() {
};
const disposable = configuration.onDidChange(e => {
if (
configuration.changed(e, 'heatmap.ageThreshold') ||
configuration.changed(e, 'heatmap.hotColor') ||
configuration.changed(e, 'heatmap.coldColor')
) {
if (configuration.changed(e, ['heatmap.ageThreshold', 'heatmap.hotColor', 'heatmap.coldColor'])) {
disposable.dispose();
heatmapColors = undefined;
}
@ -111,7 +101,7 @@ export class Annotations {
) {
const [r, g, b, a] = this.getHeatmapColor(date, heatmap);
const { fadeLines, locations } = Container.instance.config.heatmap;
const { fadeLines, locations } = configuration.get('heatmap');
const gutter = locations.includes(HeatmapLocations.Gutter);
const line = locations.includes(HeatmapLocations.Line);
const scrollbar = locations.includes(HeatmapLocations.Scrollbar);

+ 10
- 11
src/annotations/blameAnnotationProvider.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { CancellationToken, Disposable, Hover, languages, Position, Range, TextDocument, TextEditor } from 'vscode';
import { FileAnnotationType } from '../config';
import { configuration } from '../configuration';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitBlame, GitCommit } from '../git/models';
@ -69,7 +70,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
dates.sort((a, b) => a.getTime() - b.getTime());
const coldThresholdDate = new Date();
coldThresholdDate.setDate(coldThresholdDate.getDate() - (this.container.config.heatmap.ageThreshold || 90));
coldThresholdDate.setDate(coldThresholdDate.getDate() - (configuration.get('heatmap.ageThreshold') || 90));
const coldThresholdTimestamp = coldThresholdDate.getTime();
const hotDates: Date[] = [];
@ -132,11 +133,8 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
}
registerHoverProviders(providers: { details: boolean; changes: boolean }) {
if (
!this.container.config.hovers.enabled ||
!this.container.config.hovers.annotations.enabled ||
(!providers.details && !providers.changes)
) {
const cfg = configuration.get('hovers');
if (!cfg.enabled || !cfg.annotations.enabled || (!providers.details && !providers.changes)) {
return;
}
@ -155,7 +153,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
position: Position,
_token: CancellationToken,
): Promise<Hover | undefined> {
if (this.container.config.hovers.annotations.over !== 'line' && position.character !== 0) return undefined;
if (configuration.get('hovers.annotations.over') !== 'line' && position.character !== 0) return undefined;
if (this.document.uri.toString() !== document.uri.toString()) return undefined;
@ -188,16 +186,17 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
const commitLine = commit.lines.find(l => l.line === line) ?? commit.lines[0];
editorLine = commitLine.originalLine - 1;
const cfg = configuration.get('hovers');
return Hovers.detailsMessage(
commit,
await GitUri.fromUri(document.uri),
editorLine,
this.container.config.hovers.detailsMarkdownFormat,
this.container.config.defaultDateFormat,
cfg.detailsMarkdownFormat,
configuration.get('defaultDateFormat'),
{
autolinks: this.container.config.hovers.autolinks.enabled,
autolinks: cfg.autolinks.enabled,
pullRequests: {
enabled: this.container.config.hovers.pullRequests.enabled,
enabled: cfg.pullRequests.enabled,
},
},
);

+ 23
- 20
src/annotations/fileAnnotationController.ts Zobrazit soubor

@ -112,31 +112,33 @@ export class FileAnnotationController implements Disposable {
}
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
const cfg = this.container.config;
const initializing = e == null;
if (configuration.changed(e, 'blame.highlight') || configuration.changed(e, 'changes.locations')) {
if (configuration.changed(e, ['blame.highlight', 'changes.locations'])) {
this.updateDecorations(false);
}
let toggleMode;
if (configuration.changed(e, 'blame.toggleMode')) {
this._toggleModes.set(FileAnnotationType.Blame, cfg.blame.toggleMode);
if (!initializing && cfg.blame.toggleMode === AnnotationsToggleMode.File) {
toggleMode = configuration.get('blame.toggleMode');
this._toggleModes.set(FileAnnotationType.Blame, toggleMode);
if (!initializing && toggleMode === AnnotationsToggleMode.File) {
void this.clearAll();
}
}
if (configuration.changed(e, 'changes.toggleMode')) {
this._toggleModes.set(FileAnnotationType.Changes, cfg.changes.toggleMode);
if (!initializing && cfg.changes.toggleMode === AnnotationsToggleMode.File) {
toggleMode = configuration.get('changes.toggleMode');
this._toggleModes.set(FileAnnotationType.Changes, toggleMode);
if (!initializing && toggleMode === AnnotationsToggleMode.File) {
void this.clearAll();
}
}
if (configuration.changed(e, 'heatmap.toggleMode')) {
this._toggleModes.set(FileAnnotationType.Heatmap, cfg.heatmap.toggleMode);
if (!initializing && cfg.heatmap.toggleMode === AnnotationsToggleMode.File) {
toggleMode = configuration.get('heatmap.toggleMode');
this._toggleModes.set(FileAnnotationType.Heatmap, toggleMode);
if (!initializing && toggleMode === AnnotationsToggleMode.File) {
void this.clearAll();
}
}
@ -144,14 +146,16 @@ export class FileAnnotationController implements Disposable {
if (initializing) return;
if (
configuration.changed(e, 'blame') ||
configuration.changed(e, 'changes') ||
configuration.changed(e, 'heatmap') ||
configuration.changed(e, 'hovers') ||
configuration.changed(e, 'defaultDateFormat') ||
configuration.changed(e, 'defaultDateSource') ||
configuration.changed(e, 'defaultDateStyle') ||
configuration.changed(e, 'defaultGravatarsStyle')
configuration.changed(e, [
'blame',
'changes',
'heatmap',
'hovers',
'defaultDateFormat',
'defaultDateSource',
'defaultDateStyle',
'defaultGravatarsStyle',
])
) {
// Since the configuration has changed -- reset any visible annotations
for (const provider of this._annotationProviders.values()) {
@ -544,7 +548,7 @@ export class FileAnnotationController implements Disposable {
Decorations.changesLineChangedAnnotation?.dispose();
Decorations.changesLineDeletedAnnotation?.dispose();
const { locations } = this.container.config.changes;
const locations = configuration.get('changes.locations');
type RGB = [number, number, number];
let addedColor: RGB;
@ -633,8 +637,7 @@ export class FileAnnotationController implements Disposable {
Decorations.gutterBlameHighlight?.dispose();
Decorations.gutterBlameHighlight = undefined;
const { highlight } = this.container.config.blame;
const highlight = configuration.get('blame.highlight');
if (highlight.enabled) {
const { locations } = highlight;

+ 5
- 5
src/annotations/gutterBlameAnnotationProvider.ts Zobrazit soubor

@ -1,5 +1,5 @@
import { DecorationOptions, Range, TextEditor, ThemableDecorationAttachmentRenderOptions } from 'vscode';
import { FileAnnotationType, GravatarDefaultStyle } from '../configuration';
import { configuration, FileAnnotationType, GravatarDefaultStyle } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
@ -45,7 +45,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
const sw = new Stopwatch(cc!);
const cfg = this.container.config.blame;
const cfg = configuration.get('blame');
// Precalculate the formatting options so we don't need to do it on each iteration
const tokenOptions = getTokensFromTemplate(cfg.format).reduce<{
@ -61,13 +61,13 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
}
const options: CommitFormatOptions = {
dateFormat: cfg.dateFormat === null ? this.container.config.defaultDateFormat : cfg.dateFormat,
dateFormat: cfg.dateFormat === null ? configuration.get('defaultDateFormat') : cfg.dateFormat,
getBranchAndTagTips: getBranchAndTagTips,
tokenOptions: tokenOptions,
};
const avatars = cfg.avatars;
const gravatarDefault = this.container.config.defaultGravatarsStyle;
const gravatarDefault = configuration.get('defaultGravatarsStyle');
const separateLines = cfg.separateLines;
const renderOptions = Annotations.gutterRenderOptions(
separateLines,
@ -171,7 +171,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
sw.stop({ suffix: ' to apply all gutter blame annotations' });
}
this.registerHoverProviders(this.container.config.hovers.annotations);
this.registerHoverProviders(configuration.get('hovers.annotations'));
return true;
}

+ 4
- 5
src/annotations/gutterChangesAnnotationProvider.ts Zobrazit soubor

@ -12,7 +12,7 @@ import {
TextEditorDecorationType,
TextEditorRevealType,
} from 'vscode';
import { FileAnnotationType } from '../configuration';
import { configuration, FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitCommit, GitDiff } from '../git/models';
import { Hovers } from '../hovers/hovers';
@ -280,9 +280,8 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase
}
registerHoverProvider() {
if (!this.container.config.hovers.enabled || !this.container.config.hovers.annotations.enabled) {
return;
}
const cfg = configuration.get('hovers');
if (!cfg.enabled || !cfg.annotations.enabled) return;
this.hoverProviderDisposable = languages.registerHoverProvider(
{ pattern: this.document.uri.fsPath },
@ -299,7 +298,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase
_token: CancellationToken,
): Promise<Hover | undefined> {
if (this.state == null) return undefined;
if (this.container.config.hovers.annotations.over !== 'line' && position.character !== 0) return undefined;
if (configuration.get('hovers.annotations.over') !== 'line' && position.character !== 0) return undefined;
const { commit, diffs } = this.state;

+ 1
- 1
src/annotations/gutterHeatmapBlameAnnotationProvider.ts Zobrazit soubor

@ -57,7 +57,7 @@ export class GutterHeatmapBlameAnnotationProvider extends BlameAnnotationProvide
sw.stop({ suffix: ' to apply all heatmap annotations' });
}
// this.registerHoverProviders(this.container.config.hovers.annotations);
// this.registerHoverProviders(configuration.get('hovers.annotations'));
return true;
}

+ 3
- 3
src/annotations/lineAnnotationController.ts Zobrazit soubor

@ -64,7 +64,7 @@ export class LineAnnotationController implements Disposable {
if (!configuration.changed(e, 'currentLine')) return;
if (configuration.changed(e, 'currentLine.enabled')) {
if (this.container.config.currentLine.enabled) {
if (configuration.get('currentLine.enabled')) {
this._enabled = true;
this.resume();
} else {
@ -207,7 +207,7 @@ export class LineAnnotationController implements Disposable {
this._editor = editor;
}
const cfg = this.container.config.currentLine;
const cfg = configuration.get('currentLine');
if (this.suspended) {
if (cc != null) {
cc.exitDetails = ` ${GlyphChars.Dot} Skipped because the controller is suspended`;
@ -303,7 +303,7 @@ export class LineAnnotationController implements Disposable {
// l,
cfg.format,
{
dateFormat: cfg.dateFormat === null ? this.container.config.defaultDateFormat : cfg.dateFormat,
dateFormat: cfg.dateFormat === null ? configuration.get('defaultDateFormat') : cfg.dateFormat,
getBranchAndTagTips: getBranchAndTagTips,
pullRequestOrRemote: prs?.get(commit.ref),
pullRequestPendingMessage: `PR ${GlyphChars.Ellipsis}`,

+ 2
- 4
src/api/actionRunners.ts Zobrazit soubor

@ -167,7 +167,7 @@ export class ActionRunners implements Disposable {
}
get(action: Actions): RegisteredActionRunner[] | undefined {
return filterOnlyEnabledRunners(this.container.config, this._actionRunners.get(action));
return filterOnlyEnabledRunners(configuration.get('partners'), this._actionRunners.get(action));
}
has(action: Actions): boolean {
@ -334,10 +334,8 @@ export class ActionRunners implements Disposable {
}
}
function filterOnlyEnabledRunners(config: Config, runners: RegisteredActionRunner[] | undefined) {
function filterOnlyEnabledRunners(partners: Config['partners'], runners: RegisteredActionRunner[] | undefined) {
if (runners == null || runners.length === 0) return undefined;
const partners = config.partners;
if (partners == null) return runners;
return runners.filter(

+ 2
- 1
src/avatars.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { EventEmitter, Uri } from 'vscode';
import { GravatarDefaultStyle } from './config';
import { configuration } from './configuration';
import { Container } from './container';
import { GitRevisionReference } from './git/models';
import { getGitHubNoReplyAddressParts } from './git/remotes/github';
@ -184,7 +185,7 @@ async function getAvatarUriFromRemoteProvider(
try {
let account;
if (Container.instance.config.integrations.enabled) {
if (configuration.get('integrations.enabled')) {
// if (typeof repoPathOrCommit === 'string') {
// const remote = await Container.instance.git.getRichRemoteProvider(repoPathOrCommit);
// account = await remote?.provider.getAccountForEmail(email, { avatarSize: size });

+ 7
- 12
src/codelens/codeLensController.ts Zobrazit soubor

@ -35,17 +35,12 @@ export class GitCodeLensController implements Disposable {
}
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (
configuration.changed(e, 'codeLens') ||
configuration.changed(e, 'defaultDateFormat') ||
configuration.changed(e, 'defaultDateSource') ||
configuration.changed(e, 'defaultDateStyle')
) {
if (configuration.changed(e, ['codeLens', 'defaultDateFormat', 'defaultDateSource', 'defaultDateStyle'])) {
if (e != null) {
Logger.log('CodeLens config changed; resetting CodeLens provider');
}
const cfg = this.container.config.codeLens;
const cfg = configuration.get('codeLens');
if (cfg.enabled && (cfg.recentChange.enabled || cfg.authors.enabled)) {
this.ensureProvider();
} else {
@ -60,16 +55,16 @@ export class GitCodeLensController implements Disposable {
private onBlameStateChanged(e: DocumentBlameStateChangeEvent<GitDocumentState>) {
// Only reset if we have saved, since the CodeLens won't naturally be re-rendered
if (this._provider === undefined || !e.blameable) return;
if (this._provider == null || !e.blameable) return;
Logger.log('Blame state changed; resetting CodeLens provider');
this._provider.reset('saved');
}
private onDirtyIdleTriggered(e: DocumentDirtyIdleTriggerEvent<GitDocumentState>) {
if (this._provider === undefined || !e.document.isBlameable) return;
if (this._provider == null || !e.document.isBlameable) return;
const maxLines = this.container.config.advanced.blame.sizeThresholdAfterEdit;
const maxLines = configuration.get('advanced.blame.sizeThresholdAfterEdit');
if (maxLines > 0 && e.document.lineCount > maxLines) return;
Logger.log('Dirty idle triggered; resetting CodeLens provider');
@ -80,7 +75,7 @@ export class GitCodeLensController implements Disposable {
if (!this._canToggle) return;
Logger.log('toggleCodeLens()');
if (this._provider !== undefined) {
if (this._provider != null) {
this._providerDisposable?.dispose();
this._provider = undefined;
@ -91,7 +86,7 @@ export class GitCodeLensController implements Disposable {
}
private ensureProvider() {
if (this._provider !== undefined) {
if (this._provider != null) {
this._provider.reset();
return;

+ 6
- 6
src/codelens/codeLensProvider.ts Zobrazit soubor

@ -120,7 +120,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (document.isDirty) {
// Only allow dirty blames if we are idle
if (trackedDocument.isDirtyIdle) {
const maxLines = this.container.config.advanced.blame.sizeThresholdAfterEdit;
const maxLines = configuration.get('advanced.blame.sizeThresholdAfterEdit');
if (maxLines > 0 && document.lineCount > maxLines) {
dirty = true;
}
@ -511,7 +511,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
let title = `${recentCommit.author.name}, ${
lens.dateFormat == null ? recentCommit.formattedDate : recentCommit.formatDate(lens.dateFormat)
}`;
if (this.container.config.debug) {
if (configuration.get('debug')) {
title += ` [${lens.languageId}: ${SymbolKind[lens.symbol.kind]}(${lens.range.start.character}-${
lens.range.end.character
}${
@ -582,7 +582,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
const author = first(blame.authors.values()).name;
let title = `${count} ${count > 1 ? 'authors' : 'author'} (${author}${count > 1 ? ' and others' : ''})`;
if (this.container.config.debug) {
if (configuration.get('debug')) {
title += ` [${lens.languageId}: ${SymbolKind[lens.symbol.kind]}(${lens.range.start.character}-${
lens.range.end.character
}${
@ -872,10 +872,10 @@ export class GitCodeLensProvider implements CodeLensProvider {
private getDirtyTitle(cfg: CodeLensConfig) {
if (cfg.recentChange.enabled && cfg.authors.enabled) {
return this.container.config.strings.codeLens.unsavedChanges.recentChangeAndAuthors;
return configuration.get('strings.codeLens.unsavedChanges.recentChangeAndAuthors');
}
if (cfg.recentChange.enabled) return this.container.config.strings.codeLens.unsavedChanges.recentChangeOnly;
return this.container.config.strings.codeLens.unsavedChanges.authorsOnly;
if (cfg.recentChange.enabled) return configuration.get('strings.codeLens.unsavedChanges.recentChangeOnly');
return configuration.get('strings.codeLens.unsavedChanges.authorsOnly');
}
}

+ 2
- 1
src/commands/copyShaToClipboard.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { env, TextEditor, Uri } from 'vscode';
import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
@ -28,7 +29,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
protected override preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) {
if (isCommandContextViewNodeHasCommit(context)) {
args = { ...args };
args.sha = this.container.config.advanced.abbreviateShaOnCopy
args.sha = configuration.get('advanced.abbreviateShaOnCopy')
? context.node.commit.shortSha
: context.node.commit.sha;
return this.execute(

+ 2
- 1
src/commands/externalDiff.ts Zobrazit soubor

@ -1,6 +1,7 @@
import { env, SourceControlResourceState, Uri, window } from 'vscode';
import { ScmResource } from '../@types/vscode.git.resources';
import { ScmResourceGroupType, ScmStatus } from '../@types/vscode.git.resources.enums';
import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
@ -153,7 +154,7 @@ export class ExternalDiffCommand extends Command {
}
const tool =
this.container.config.advanced.externalDiffTool || (await this.container.git.getDiffTool(repoPath));
configuration.get('advanced.externalDiffTool') || (await this.container.git.getDiffTool(repoPath));
if (!tool) {
const viewDocs = 'View Git Docs';
const result = await window.showWarningMessage(

+ 2
- 1
src/commands/git/search.ts Zobrazit soubor

@ -1,3 +1,4 @@
import { configuration } from '../../configuration';
import { ContextKeys, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { getContext } from '../../context';
@ -104,7 +105,7 @@ export class SearchGitCommand extends QuickCommand {
title: this.title,
};
const cfg = this.container.config.gitCommands.search;
const cfg = configuration.get('gitCommands.search');
if (state.matchAll == null) {
state.matchAll = cfg.matchAll;
}

+ 2
- 1
src/commands/gitCommands.utils.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { GitCommandSorting } from '../config';
import { configuration } from '../configuration';
import { ContextKeys } from '../constants';
import type { Container } from '../container';
import { getContext } from '../context';
@ -96,7 +97,7 @@ export class PickCommandStep implements QuickPickStep {
: new WorktreeGitCommand(container, args?.command === 'worktree' ? args : undefined),
].filter(<T>(i: T | undefined): i is T => i != null);
if (this.container.config.gitCommands.sortBy === GitCommandSorting.Usage) {
if (configuration.get('gitCommands.sortBy') === GitCommandSorting.Usage) {
const usage = this.container.storage.getWorkspace<Usage>(WorkspaceStorageKeys.GitCommandPaletteUsage);
if (usage != null) {
this.items.sort((a, b) => (usage[b.key] ?? 0) - (usage[a.key] ?? 0));

+ 2
- 1
src/commands/quickCommand.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode';
import { configuration } from '../configuration';
import type { Container } from '../container';
import { Keys } from '../keyboard';
import { Directive, DirectiveQuickPickItem } from '../quickpicks/items/directive';
@ -180,7 +181,7 @@ export abstract class QuickCommand implements QuickPickItem {
return override != null
? override
: !this.container.config.gitCommands.skipConfirmations.includes(this.skipConfirmKey);
: !configuration.get('gitCommands.skipConfirmations').includes(this.skipConfirmKey);
}
isMatch(key: string) {

+ 2
- 1
src/commands/searchCommits.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { executeGitCommand } from '../commands/gitCommands.actions';
import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { SearchPattern } from '../git/search';
@ -51,7 +52,7 @@ export class SearchCommitsCommand extends Command {
repo: args?.repoPath,
...args?.search,
showResultsInSideBar:
this.container.config.gitCommands.search.showResultsInSideBar ?? args?.showResultsInSideBar,
configuration.get('gitCommands.search.showResultsInSideBar') ?? args?.showResultsInSideBar,
},
}));
}

+ 6
- 8
src/commands/switchMode.ts Zobrazit soubor

@ -52,11 +52,10 @@ export class ToggleReviewModeCommand extends Command {
@log({ args: false, singleLine: true, timed: false })
async execute() {
if (this.container.config.modes == null || !Object.keys(this.container.config.modes).includes('review')) {
return;
}
const modes = configuration.get('modes');
if (modes == null || !Object.keys(modes).includes('review')) return;
const mode = this.container.config.mode.active === 'review' ? undefined : 'review';
const mode = configuration.get('mode.active') === 'review' ? undefined : 'review';
await configuration.update('mode.active', mode, ConfigurationTarget.Global);
}
}
@ -69,11 +68,10 @@ export class ToggleZenModeCommand extends Command {
@log({ args: false, singleLine: true, timed: false })
async execute() {
if (this.container.config.modes == null || !Object.keys(this.container.config.modes).includes('zen')) {
return;
}
const modes = configuration.get('modes');
if (modes == null || !Object.keys(modes).includes('zen')) return;
const mode = this.container.config.mode.active === 'zen' ? undefined : 'zen';
const mode = configuration.get('mode.active') === 'zen' ? undefined : 'zen';
await configuration.update('mode.active', mode, ConfigurationTarget.Global);
}
}

+ 0
- 10
src/container.ts Zobrazit soubor

@ -9,7 +9,6 @@ import { GitCodeLensController } from './codelens/codeLensController';
import type { ToggleFileAnnotationCommandArgs } from './commands';
import {
AnnotationsToggleMode,
Config,
configuration,
DateSource,
DateStyle,
@ -231,7 +230,6 @@ export class Container {
}
private onConfigurationChanging(e: ConfigurationChangeEvent) {
this._config = undefined;
this._mode = undefined;
if (configuration.changed(e, 'outputLevel')) {
@ -288,14 +286,6 @@ export class Container {
return this._commitsView;
}
private _config: Config | undefined;
get config() {
if (this._config == null) {
this._config = configuration.getAll();
}
return this._config;
}
private readonly _context: ExtensionContext;
get context() {
return this._context;

+ 57
- 55
src/env/node/git/localGitProvider.ts Zobrazit soubor

@ -211,7 +211,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
private get useCaching() {
return this.container.config.advanced.caching.enabled;
return configuration.get('advanced.caching.enabled');
}
private onRepositoryChanged(repo: Repository, e: RepositoryChangeEvent) {
@ -785,10 +785,13 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
// TODO: Add caching
const cfg = configuration.get('advanced');
// Get the most recent commit for this file name
ref = await this.git.log__file_recent(repoPath, relativePath, {
ordering: this.container.config.advanced.commitOrdering,
similarityThreshold: this.container.config.advanced.similarityThreshold,
ordering: cfg.commitOrdering,
similarityThreshold: cfg.similarityThreshold,
});
if (ref == null) return undefined;
@ -798,7 +801,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
fileMode: 'simple',
filters: ['R', 'C', 'D'],
limit: 1,
ordering: this.container.config.advanced.commitOrdering,
ordering: cfg.commitOrdering,
});
if (data == null || data.length === 0) break;
@ -1132,8 +1135,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
try {
const data = await this.git.blame(root, relativePath, uri.sha, {
args: this.container.config.advanced.blame.customArguments,
ignoreWhitespace: this.container.config.blame.ignoreWhitespace,
args: configuration.get('advanced.blame.customArguments'),
ignoreWhitespace: configuration.get('blame.ignoreWhitespace'),
});
const blame = GitBlameParser.parse(this.container, data, root, await this.getCurrentUser(root));
return blame;
@ -1212,9 +1215,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
try {
const data = await this.git.blame__contents(root, relativePath, contents, {
args: this.container.config.advanced.blame.customArguments,
args: configuration.get('advanced.blame.customArguments'),
correlationKey: `:${key}`,
ignoreWhitespace: this.container.config.blame.ignoreWhitespace,
ignoreWhitespace: configuration.get('blame.ignoreWhitespace'),
});
const blame = GitBlameParser.parse(this.container, data, root, await this.getCurrentUser(root));
return blame;
@ -1276,8 +1279,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
try {
const data = await this.git.blame(root, relativePath, uri.sha, {
args: this.container.config.advanced.blame.customArguments,
ignoreWhitespace: this.container.config.blame.ignoreWhitespace,
args: configuration.get('advanced.blame.customArguments'),
ignoreWhitespace: configuration.get('blame.ignoreWhitespace'),
startLine: lineToBlame,
endLine: lineToBlame,
});
@ -1327,8 +1330,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
try {
const data = await this.git.blame__contents(root, relativePath, contents, {
args: this.container.config.advanced.blame.customArguments,
ignoreWhitespace: this.container.config.blame.ignoreWhitespace,
args: configuration.get('advanced.blame.customArguments'),
ignoreWhitespace: configuration.get('blame.ignoreWhitespace'),
startLine: lineToBlame,
endLine: lineToBlame,
});
@ -1416,14 +1419,17 @@ export class LocalGitProvider implements GitProvider, Disposable {
} = await this.getBranches(repoPath, { filter: b => b.current });
if (branch != null) return branch;
const data = await this.git.rev_parse__currentBranch(repoPath, this.container.config.advanced.commitOrdering);
const commitOrdering = configuration.get('advanced.commitOrdering');
const data = await this.git.rev_parse__currentBranch(repoPath, commitOrdering);
if (data == null) return undefined;
const [name, upstream] = data[0].split('\n');
if (GitBranch.isDetached(name)) {
const [rebaseStatus, committerDate] = await Promise.all([
this.getRebaseStatus(repoPath),
this.git.log__recent_committerdate(repoPath, this.container.config.advanced.commitOrdering),
this.git.log__recent_committerdate(repoPath, commitOrdering),
]);
branch = new GitBranch(
@ -1464,18 +1470,14 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (data == null || data.length === 0) {
let current;
const data = await this.git.rev_parse__currentBranch(
repoPath!,
this.container.config.advanced.commitOrdering,
);
const commitOrdering = configuration.get('advanced.commitOrdering');
const data = await this.git.rev_parse__currentBranch(repoPath!, commitOrdering);
if (data != null) {
const [name, upstream] = data[0].split('\n');
const [rebaseStatus, committerDate] = await Promise.all([
GitBranch.isDetached(name) ? this.getRebaseStatus(repoPath!) : undefined,
this.git.log__recent_committerdate(
repoPath!,
this.container.config.advanced.commitOrdering,
),
this.git.log__recent_committerdate(repoPath!, commitOrdering),
]);
current = new GitBranch(
@ -1613,7 +1615,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const data = await this.git.log__file(root, relativePath, '@{push}..', {
argsOrFormat: ['-z', '--format=%H'],
fileMode: 'none',
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
renames: true,
});
if (!data) return undefined;
@ -1889,7 +1891,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
filters: ['M'],
linesOfContext: 0,
renames: true,
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
const diff = GitDiffParser.parse(data);
@ -1975,7 +1977,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const data = await this.git.diff__contents(root, relativePath, ref, contents, {
...options,
filters: ['M'],
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
const diff = GitDiffParser.parse(data);
@ -2029,7 +2031,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
): Promise<GitFile[] | undefined> {
try {
const data = await this.git.diff__name_status(repoPath, ref1, ref2, {
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
...options,
});
if (!data) return undefined;
@ -2094,7 +2096,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
): Promise<GitLog | undefined> {
const cc = Logger.getCorrelationContext();
const limit = options?.limit ?? this.container.config.advanced.maxListItems ?? 0;
const limit = options?.limit ?? configuration.get('advanced.maxListItems') ?? 0;
try {
// const parser = GitLogParser.defaultParser;
@ -2104,8 +2106,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
// args: parser.arguments,
limit: limit,
merges: options?.merges == null ? true : options.merges,
ordering: options?.ordering ?? this.container.config.advanced.commitOrdering,
similarityThreshold: this.container.config.advanced.similarityThreshold,
ordering: options?.ordering ?? configuration.get('advanced.commitOrdering'),
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
// const commits = [];
@ -2177,7 +2179,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
): Promise<Set<string> | undefined> {
const cc = Logger.getCorrelationContext();
const limit = options?.limit ?? this.container.config.advanced.maxListItems ?? 0;
const limit = options?.limit ?? configuration.get('advanced.maxListItems') ?? 0;
try {
const parser = GitLogParser.createSingle('%H');
@ -2187,9 +2189,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
argsOrFormat: parser.arguments,
limit: limit,
merges: options?.merges == null ? true : options.merges,
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
since: options?.since,
ordering: options?.ordering ?? this.container.config.advanced.commitOrdering,
ordering: options?.ordering ?? configuration.get('advanced.commitOrdering'),
});
const commits = new Set(parser.parse(data));
@ -2219,7 +2221,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
return log;
}
moreLimit = moreLimit ?? this.container.config.advanced.maxSearchItems ?? 0;
moreLimit = moreLimit ?? configuration.get('advanced.maxSearchItems') ?? 0;
// If the log is for a range, then just get everything prior + more
if (GitRevision.isRange(log.sha)) {
@ -2269,8 +2271,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
search = { matchAll: false, matchCase: false, matchRegex: true, ...search };
try {
const limit = options?.limit ?? this.container.config.advanced.maxSearchItems ?? 0;
const similarityThreshold = this.container.config.advanced.similarityThreshold;
const limit = options?.limit ?? configuration.get('advanced.maxSearchItems') ?? 0;
const similarityThreshold = configuration.get('advanced.similarityThreshold');
const operations = SearchPattern.parseSearchOperations(search.pattern);
@ -2350,7 +2352,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
const data = await this.git.log__search(repoPath, args, {
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
...options,
limit: limit,
useShow: useShow,
@ -2388,7 +2390,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
options?: { limit?: number; ordering?: 'date' | 'author-date' | 'topo' | null },
): (limit: number | undefined) => Promise<GitLog> {
return async (limit: number | undefined) => {
limit = limit ?? this.container.config.advanced.maxSearchItems ?? 0;
limit = limit ?? configuration.get('advanced.maxSearchItems') ?? 0;
const moreLog = await this.getLogForSearch(log.repoPath, search, {
...options,
@ -2447,7 +2449,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
options = { reverse: false, ...options };
if (options.renames == null) {
options.renames = this.container.config.advanced.fileHistoryFollowsRenames;
options.renames = configuration.get('advanced.fileHistoryFollowsRenames');
}
let key = 'log';
@ -2456,13 +2458,13 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
if (options.all == null) {
options.all = this.container.config.advanced.fileHistoryShowAllBranches;
options.all = configuration.get('advanced.fileHistoryShowAllBranches');
}
if (options.all) {
key += ':all';
}
options.limit = options.limit ?? this.container.config.advanced.maxListItems ?? 0;
options.limit = options.limit ?? configuration.get('advanced.maxListItems') ?? 0;
if (options.limit) {
key += `:n${options.limit}`;
}
@ -2604,7 +2606,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
const data = await this.git.log__file(root, relativePath, ref, {
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
...options,
firstParent: options.renames,
startLine: range == null ? undefined : range.start.line + 1,
@ -2674,7 +2676,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
return log;
}
moreLimit = moreLimit ?? this.container.config.advanced.maxSearchItems ?? 0;
moreLimit = moreLimit ?? configuration.get('advanced.maxSearchItems') ?? 0;
const ref = last(log.commits.values())?.ref;
const moreLog = await this.getLogForFile(log.repoPath, relativePath, {
@ -2913,7 +2915,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
fileMode: 'simple',
filters: filters,
limit: skip + 1,
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
reverse: true,
// startLine: editorLine != null ? editorLine + 1 : undefined,
});
@ -2927,7 +2929,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
fileMode: 'simple',
filters: ['R', 'C'],
limit: 1,
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
// startLine: editorLine != null ? editorLine + 1 : undefined
});
if (data == null || data.length === 0) {
@ -3168,7 +3170,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
fileMode: 'simple',
firstParent: firstParent,
limit: skip + 2,
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
startLine: editorLine != null ? editorLine + 1 : undefined,
});
} catch (ex) {
@ -3183,7 +3185,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
ref = await this.git.log__file_recent(repoPath, relativePath, {
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
});
return GitUri.fromFile(relativePath, repoPath, ref ?? GitRevision.deletedOrMissing);
}
@ -3207,11 +3209,11 @@ export class LocalGitProvider implements GitProvider, Disposable {
): Promise<GitReflog | undefined> {
const cc = Logger.getCorrelationContext();
const limit = options?.limit ?? this.container.config.advanced.maxListItems ?? 0;
const limit = options?.limit ?? configuration.get('advanced.maxListItems') ?? 0;
try {
// Pass a much larger limit to reflog, because we aggregate the data and we won't know how many lines we'll need
const data = await this.git.reflog(repoPath, {
ordering: this.container.config.advanced.commitOrdering,
ordering: configuration.get('advanced.commitOrdering'),
...options,
limit: limit * 100,
});
@ -3234,7 +3236,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
options?: { all?: boolean; branch?: string; limit?: number; ordering?: string | null; skip?: number },
): (limit: number) => Promise<GitReflog> {
return async (limit: number | undefined) => {
limit = limit ?? this.container.config.advanced.maxSearchItems ?? 0;
limit = limit ?? configuration.get('advanced.maxSearchItems') ?? 0;
const moreLog = await this.getIncomingActivity(reflog.repoPath, {
...options,
@ -3315,7 +3317,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
});
const data = await this.git.stash__list(repoPath, {
args: parser.arguments,
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
const commits = new Map<string, GitStashCommit>();
@ -3381,7 +3383,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const [relativePath, root] = splitPath(uri, repoPath);
const data = await this.git.status__file(root, relativePath, porcelainVersion, {
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
const status = GitStatusParser.parse(data, root, porcelainVersion);
if (status == null || !status.files.length) return undefined;
@ -3396,7 +3398,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const [relativePath, root] = splitPath(pathOrGlob, repoPath);
const data = await this.git.status__file(root, relativePath, porcelainVersion, {
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
const status = GitStatusParser.parse(data, root, porcelainVersion);
if (status == null || !status.files.length) return [];
@ -3411,7 +3413,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1;
const data = await this.git.status(repoPath, porcelainVersion, {
similarityThreshold: this.container.config.advanced.similarityThreshold,
similarityThreshold: configuration.get('advanced.similarityThreshold'),
});
const status = GitStatusParser.parse(data, repoPath, porcelainVersion);
@ -3675,7 +3677,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (!tool) {
const cc = Logger.getCorrelationContext();
tool = this.container.config.advanced.externalDiffTool || (await this.getDiffTool(root));
tool = configuration.get('advanced.externalDiffTool') || (await this.getDiffTool(root));
if (tool == null) throw new Error('No diff tool found');
Logger.log(cc, `Using tool=${tool}`);
@ -3710,7 +3712,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (!tool) {
const cc = Logger.getCorrelationContext();
tool = this.container.config.advanced.externalDirectoryDiffTool || (await this.getDiffTool(repoPath));
tool = configuration.get('advanced.externalDirectoryDiffTool') || (await this.getDiffTool(repoPath));
if (tool == null) throw new Error('No diff tool found');
Logger.log(cc, `Using tool=${tool}`);

+ 2
- 1
src/env/node/providers.ts Zobrazit soubor

@ -1,3 +1,4 @@
import { configuration } from '../../configuration';
import { Container } from '../../container';
import { GitCommandOptions } from '../../git/commandOptions';
import { GitProvider } from '../../git/gitProvider';
@ -26,7 +27,7 @@ export async function getSupportedGitProviders(container: Container): Promise
new VslsGitProvider(container, new VslsGit(git)),
];
if (container.config.virtualRepositories.enabled) {
if (configuration.get('virtualRepositories.enabled')) {
const GitHubGitProvider = (await import(/* webpackChunkName: "github" */ '../../plus/github/githubGitProvider'))
.GitHubGitProvider;
providers.push(new GitHubGitProvider(container));

+ 4
- 4
src/extension.ts Zobrazit soubor

@ -218,7 +218,7 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev
if (previousVersion == null) {
Logger.log(`GitLens first-time install; window.focused=${window.state.focused}`);
if (container.config.showWelcomeOnInstall === false) return;
if (configuration.get('showWelcomeOnInstall') === false) return;
if (window.state.focused) {
await container.storage.delete(StorageKeys.PendingWelcomeOnFocus);
@ -234,7 +234,7 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev
// If the window is now focused and we are pending the welcome, clear the pending state and show the welcome
if (container.storage.get(StorageKeys.PendingWelcomeOnFocus) === true) {
void container.storage.delete(StorageKeys.PendingWelcomeOnFocus);
if (container.config.showWelcomeOnInstall) {
if (configuration.get('showWelcomeOnInstall')) {
void executeCommand(Commands.ShowWelcomePage);
}
}
@ -263,7 +263,7 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev
void executeCommand(Commands.ShowHomeView);
if (container.config.showWhatsNewAfterUpgrades) {
if (configuration.get('showWhatsNewAfterUpgrades')) {
if (window.state.focused) {
await container.storage.delete(StorageKeys.PendingWhatsNewOnFocus);
await Messages.showWhatsNewMessage(version);
@ -278,7 +278,7 @@ async function showWelcomeOrWhatsNew(container: Container, version: string, prev
// If the window is now focused and we are pending the what's new, clear the pending state and show the what's new
if (container.storage.get(StorageKeys.PendingWhatsNewOnFocus) === true) {
void container.storage.delete(StorageKeys.PendingWhatsNewOnFocus);
if (container.config.showWhatsNewAfterUpgrades) {
if (configuration.get('showWhatsNewAfterUpgrades')) {
void Messages.showWhatsNewMessage(version);
}
}

+ 12
- 12
src/git/formatters/commitFormatter.ts Zobrazit soubor

@ -15,7 +15,7 @@ import {
ShowQuickCommitFileCommand,
} from '../../commands';
import { Command } from '../../commands/base';
import { DateStyle, FileAnnotationType } from '../../configuration';
import { configuration, DateStyle, FileAnnotationType } from '../../configuration';
import { Commands, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { emojify } from '../../emojis';
@ -137,7 +137,7 @@ export class CommitFormatter extends Formatter {
private get _pullRequestDateOrAgo() {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return dateStyle === DateStyle.Absolute ? this._pullRequestDate : this._pullRequestDateAgo;
}
@ -147,7 +147,7 @@ export class CommitFormatter extends Formatter {
get agoOrDate(): string {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return this._padOrTruncate(
dateStyle === DateStyle.Absolute ? this._date : this._dateAgo,
this._options.tokenOptions.agoOrDate,
@ -156,7 +156,7 @@ export class CommitFormatter extends Formatter {
get agoOrDateShort(): string {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return this._padOrTruncate(
dateStyle === DateStyle.Absolute ? this._date : this._dateAgoShort,
this._options.tokenOptions.agoOrDateShort,
@ -177,7 +177,7 @@ export class CommitFormatter extends Formatter {
get authorAgoOrDate(): string {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return this._padOrTruncate(
dateStyle === DateStyle.Absolute ? this._authorDate : this._authorDateAgo,
this._options.tokenOptions.authorAgoOrDate,
@ -186,7 +186,7 @@ export class CommitFormatter extends Formatter {
get authorAgoOrDateShort(): string {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return this._padOrTruncate(
dateStyle === DateStyle.Absolute ? this._authorDate : this._authorDateAgoShort,
this._options.tokenOptions.authorAgoOrDateShort,
@ -208,7 +208,7 @@ export class CommitFormatter extends Formatter {
}
get avatar(): string | Promise<string> {
if (!this._options.markdown || !Container.instance.config.hovers.avatars) {
if (!this._options.markdown || !configuration.get('hovers.avatars')) {
return this._padOrTruncate('', this._options.tokenOptions.avatar);
}
@ -233,9 +233,9 @@ export class CommitFormatter extends Formatter {
}
private async _getAvatarMarkdown(title: string, size?: number) {
size = size ?? Container.instance.config.hovers.avatarSize;
size = size ?? configuration.get('hovers.avatarSize');
const avatarPromise = this._item.getAvatarUri({
defaultStyle: Container.instance.config.defaultGravatarsStyle,
defaultStyle: configuration.get('defaultGravatarsStyle'),
size: size,
});
return this._padOrTruncate(
@ -363,7 +363,7 @@ export class CommitFormatter extends Formatter {
}, ${pr.formatDateFromNow()}")`;
} else if (pr instanceof PromiseCancelledError) {
commands += `${separator}[$(git-pull-request) PR $(loading~spin)](command:${Commands.RefreshHover} "Searching for a Pull Request (if any) that introduced this commit...")`;
} else if (pr.provider != null && Container.instance.config.integrations.enabled) {
} else if (pr.provider != null && configuration.get('integrations.enabled')) {
commands += `${separator}[$(plug) Connect to ${pr.provider.name}${
GlyphChars.Ellipsis
}](${ConnectRemoteProviderCommand.getMarkdownCommandArgs(pr)} "Connect to ${
@ -415,7 +415,7 @@ export class CommitFormatter extends Formatter {
get committerAgoOrDate(): string {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return this._padOrTruncate(
dateStyle === DateStyle.Absolute ? this._committerDate : this._committerDateAgo,
this._options.tokenOptions.committerAgoOrDate,
@ -424,7 +424,7 @@ export class CommitFormatter extends Formatter {
get committerAgoOrDateShort(): string {
const dateStyle =
this._options.dateStyle != null ? this._options.dateStyle : Container.instance.config.defaultDateStyle;
this._options.dateStyle != null ? this._options.dateStyle : configuration.get('defaultDateStyle');
return this._padOrTruncate(
dateStyle === DateStyle.Absolute ? this._committerDate : this._committerDateAgoShort,
this._options.tokenOptions.committerAgoOrDateShort,

+ 1
- 1
src/git/gitProviderService.ts Zobrazit soubor

@ -312,7 +312,7 @@ export class GitProviderService implements Disposable {
// }
// get useCaching() {
// return this.container.config.advanced.caching.enabled;
// return configuration.get('advanced.caching.enabled');
// }
/**

+ 2
- 2
src/git/models/reference.ts Zobrazit soubor

@ -1,5 +1,5 @@
import { configuration } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranch } from './branch';
const rangeRegex = /^(\S*?)(\.\.\.?)(\S*)\s*$/;
@ -74,7 +74,7 @@ export namespace GitRevision {
if (!force && !isShaLike(ref)) return ref;
// Don't allow shas to be shortened to less than 5 characters
const len = Math.max(5, Container.instance.config.advanced.abbreviatedShaLength);
const len = Math.max(5, configuration.get('advanced.abbreviatedShaLength'));
// If we have a suffix, append it
const match = shaShortenRegex.exec(ref);

+ 16
- 6
src/git/models/repository.ts Zobrazit soubor

@ -149,14 +149,14 @@ export class Repository implements Disposable {
}
if (short) {
return formatDate(date, Container.instance.config.defaultDateShortFormat ?? 'short');
return formatDate(date, configuration.get('defaultDateShortFormat') ?? 'short');
}
let format =
Container.instance.config.defaultDateFormat ??
`dddd, MMMM Do, YYYY [at] ${Container.instance.config.defaultTimeFormat ?? 'h:mma'}`;
configuration.get('defaultDateFormat') ??
`dddd, MMMM Do, YYYY [at] ${configuration.get('defaultTimeFormat') ?? 'h:mma'}`;
if (!/[hHm]/.test(format)) {
format += ` [at] ${Container.instance.config.defaultTimeFormat ?? 'h:mma'}`;
format += ` [at] ${configuration.get('defaultTimeFormat') ?? 'h:mma'}`;
}
return formatDate(date, format);
}
@ -773,7 +773,12 @@ export class Repository implements Disposable {
this.path,
));
} else {
await repo?.push(branch.getRemoteName(), branch.name, undefined, options?.force ? ForcePushMode.ForceWithLease : undefined);
await repo?.push(
branch.getRemoteName(),
branch.name,
undefined,
options?.force ? ForcePushMode.ForceWithLease : undefined,
);
}
}
} else if (options?.reference != null) {
@ -783,7 +788,12 @@ export class Repository implements Disposable {
const branch = await this.getBranch();
if (branch == null) return;
await repo?.push(branch.getRemoteName(), `${options.reference.ref}:${branch.getNameWithoutRemote()}`, undefined, options?.force ? ForcePushMode.ForceWithLease : undefined);
await repo?.push(
branch.getRemoteName(),
`${options.reference.ref}:${branch.getNameWithoutRemote()}`,
undefined,
options?.force ? ForcePushMode.ForceWithLease : undefined,
);
} else {
void (await executeCoreGitCommand(
options?.force ? CoreGitCommands.PushForce : CoreGitCommands.Push,

+ 6
- 4
src/hovers/hovers.ts Zobrazit soubor

@ -1,6 +1,7 @@
import { CancellationToken, MarkdownString, TextDocument } from 'vscode';
import { hrtime } from '@env/hrtime';
import { DiffWithCommand, ShowQuickCommitCommand } from '../commands';
import { configuration } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatter } from '../git/formatters';
@ -272,7 +273,7 @@ export namespace Hovers {
}
function getDiffFromHunkLine(hunkLine: GitDiffHunkLine, diffStyle?: 'line' | 'hunk'): string {
if (diffStyle === 'hunk' || (diffStyle == null && Container.instance.config.hovers.changesDiff === 'hunk')) {
if (diffStyle === 'hunk' || (diffStyle == null && configuration.get('hovers.changesDiff') === 'hunk')) {
return getDiffFromHunk(hunkLine.hunk);
}
@ -287,10 +288,11 @@ export namespace Hovers {
const start = hrtime();
const cfg = configuration.get('hovers');
if (
!Containerclass="p">.instance.config.hovers.autolinks.enabled ||
!Containerclass="p">.instance.config.hovers.autolinks.enhanced ||
!CommitFormatter.has(Containerclass="p">.instance.config.hovers.detailsMarkdownFormat, 'message')
!cfg.autolinks.enabled ||
!cfg.autolinks.enhanced ||
!CommitFormatter.has(cfg.detailsMarkdownFormat, 'message')
) {
Logger.debug(cc, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);

+ 15
- 10
src/hovers/lineHoverController.ts Zobrazit soubor

@ -50,7 +50,8 @@ export class LineHoverController implements Disposable {
return;
}
if (this.container.config.hovers.enabled && this.container.config.hovers.currentLine.enabled) {
const cfg = configuration.get('hovers');
if (cfg.enabled && cfg.currentLine.enabled) {
this.container.lineTracker.subscribe(
this,
this.container.lineTracker.onDidChangeActiveLines(this.onActiveLinesChanged, this),
@ -103,13 +104,15 @@ export class LineHoverController implements Disposable {
const commit = lineState?.commit;
if (commit == null) return undefined;
const cfg = configuration.get('hovers');
// Avoid double annotations if we are showing the whole-file hover blame annotations
if (this.container.config.hovers.annotations.details) {
if (cfg.annotations.details) {
const fileAnnotations = await this.container.fileAnnotations.getAnnotationType(window.activeTextEditor);
if (fileAnnotations === FileAnnotationType.Blame) return undefined;
}
const wholeLine = this.container.config.hovers.currentLine.over === 'line';
const wholeLine = cfg.currentLine.over === 'line';
// If we aren't showing the hover over the whole line, make sure the annotation is on
if (!wholeLine && this.container.lineAnnotations.suspended) return undefined;
@ -135,12 +138,12 @@ export class LineHoverController implements Disposable {
commit,
trackedDocument.uri,
editorLine,
this.container.config.hovers.detailsMarkdownFormat,
this.container.config.defaultDateFormat,
cfg.detailsMarkdownFormat,
configuration.get('defaultDateFormat'),
{
autolinks: this.container.config.hovers.autolinks.enabled,
autolinks: cfg.autolinks.enabled,
pullRequests: {
enabled: this.container.config.hovers.pullRequests.enabled,
enabled: cfg.pullRequests.enabled,
},
},
);
@ -165,13 +168,15 @@ export class LineHoverController implements Disposable {
const commit = lineState?.commit;
if (commit == null) return undefined;
const cfg = configuration.get('hovers');
// Avoid double annotations if we are showing the whole-file hover blame annotations
if (this.container.config.hovers.annotations.changes) {
if (cfg.annotations.changes) {
const fileAnnotations = await this.container.fileAnnotations.getAnnotationType(window.activeTextEditor);
if (fileAnnotations === FileAnnotationType.Blame) return undefined;
}
const wholeLine = this.container.config.hovers.currentLine.over === 'line';
const wholeLine = cfg.currentLine.over === 'line';
// If we aren't showing the hover over the whole line, make sure the annotation is on
if (!wholeLine && this.container.lineAnnotations.suspended) return undefined;
@ -208,7 +213,7 @@ export class LineHoverController implements Disposable {
if (editor == null) return;
const cfg = this.container.config.hovers;
const cfg = configuration.get('hovers');
if (!cfg.enabled || !cfg.currentLine.enabled || (!cfg.currentLine.details && !cfg.currentLine.changes)) return;
this._uri = editor.document.uri;

+ 4
- 4
src/plus/github/githubGitProvider.ts Zobrazit soubor

@ -793,7 +793,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
for (const branch of result.values) {
const date = new Date(
this.container.config.advanced.commitOrdering === 'author-date'
configuration.get('advanced.commitOrdering') === 'author-date'
? branch.target.authoredDate
: branch.target.committedDate,
);
@ -1612,7 +1612,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
options.all = false;
// if (options.renames == null) {
// options.renames = this.container.config.advanced.fileHistoryFollowsRenames;
// options.renames = configuration.get('advanced.fileHistoryFollowsRenames');
// }
let key = 'log';
@ -1621,7 +1621,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
}
// if (options.all == null) {
// options.all = this.container.config.advanced.fileHistoryShowAllBranches;
// options.all = configuration.get('advanced.fileHistoryShowAllBranches');
// }
// if (options.all) {
// key += ':all';
@ -2678,7 +2678,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
}
private getPagingLimit(limit?: number): number {
limit = Math.min(100, limit ?? this.container.config.advanced.maxListItems ?? 100);
limit = Math.min(100, limit ?? configuration.get('advanced.maxListItems') ?? 100);
if (limit === 0) {
limit = 100;
}

+ 2
- 2
src/plus/webviews/timeline/timelineWebview.ts Zobrazit soubor

@ -205,8 +205,8 @@ export class TimelineWebview extends WebviewBase {
@debug({ args: false })
private async getState(current: Context): Promise<State> {
const access = await this.container.git.access(PlusFeatures.Timeline);
const dateFormat = this.container.config.defaultDateFormat ?? 'MMMM Do, YYYY h:mma';
const shortDateFormat = this.container.config.defaultDateShortFormat ?? 'short';
const dateFormat = configuration.get('defaultDateFormat') ?? 'MMMM Do, YYYY h:mma';
const shortDateFormat = configuration.get('defaultDateShortFormat') ?? 'short';
const period = current.period ?? defaultPeriod;
if (!access.allowed) {

+ 2
- 2
src/plus/webviews/timeline/timelineWebviewView.ts Zobrazit soubor

@ -198,8 +198,8 @@ export class TimelineWebviewView extends WebviewViewBase {
@debug({ args: false })
private async getState(current: Context): Promise<State> {
const access = await this.container.git.access(PlusFeatures.Timeline);
const dateFormat = this.container.config.defaultDateFormat ?? 'MMMM Do, YYYY h:mma';
const shortDateFormat = this.container.config.defaultDateShortFormat ?? 'short';
const dateFormat = configuration.get('defaultDateFormat') ?? 'MMMM Do, YYYY h:mma';
const shortDateFormat = configuration.get('defaultDateShortFormat') ?? 'short';
const period = current.period ?? defaultPeriod;
if (!access.allowed) {

+ 10
- 13
src/statusbar/statusBarController.ts Zobrazit soubor

@ -57,13 +57,10 @@ export class StatusBarController implements Disposable {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (configuration.changed(e, 'mode')) {
const mode =
this.container.config.mode.active && this.container.config.mode.statusBar.enabled
? this.container.config.modes?.[this.container.config.mode.active]
: undefined;
const mode = configuration.get('mode.statusBar.enabled') ? this.container.mode : undefined;
if (mode?.statusBarItemName) {
const alignment =
this.container.config.mode.statusBar.alignment !== 'left'
configuration.get('mode.statusBar.alignment') !== 'left'
? StatusBarAlignment.Right
: StatusBarAlignment.Left;
@ -100,9 +97,9 @@ export class StatusBarController implements Disposable {
if (!configuration.changed(e, 'statusBar')) return;
if (this.container.config.statusBar.enabled) {
if (configuration.get('statusBar.enabled')) {
const alignment =
this.container.config.statusBar.alignment !== 'left'
configuration.get('statusBar.alignment') !== 'left'
? StatusBarAlignment.Right
: StatusBarAlignment.Left;
@ -121,7 +118,7 @@ export class StatusBarController implements Disposable {
alignment === StatusBarAlignment.Right ? 1000 : 0,
);
this._statusBarBlame.name = 'GitLens Current Line Blame';
this._statusBarBlame.command = this.container.config.statusBar.command;
this._statusBarBlame.command = configuration.get('statusBar.command');
if (configuration.changed(e, 'statusBar.enabled')) {
this.container.lineTracker.subscribe(
@ -148,7 +145,7 @@ export class StatusBarController implements Disposable {
private onActiveLinesChanged(e: LinesChangeEvent) {
// If we need to reduceFlicker, don't clear if only the selected lines changed
let clear = !(
this.container.config.statusBar.reduceFlicker &&
configuration.get('statusBar.reduceFlicker') &&
e.reason === 'selection' &&
(e.pending || e.selections != null)
);
@ -178,7 +175,7 @@ export class StatusBarController implements Disposable {
@debug({ args: false })
private async updateBlame(editor: TextEditor, commit: GitCommit, options?: { pr?: PullRequest | null }) {
const cfg = this.container.config.statusBar;
const cfg = configuration.get('statusBar');
if (!cfg.enabled || this._statusBarBlame == null || !isTextEditor(editor)) return;
const cc = Logger.getCorrelationContext();
@ -220,7 +217,7 @@ export class StatusBarController implements Disposable {
}
this._statusBarBlame.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, {
dateFormat: cfg.dateFormat === null ? this.container.config.defaultDateFormat : cfg.dateFormat,
dateFormat: cfg.dateFormat === null ? configuration.get('defaultDateFormat') : cfg.dateFormat,
getBranchAndTagTips: getBranchAndTagTips,
messageTruncateAtNewLine: true,
pullRequestOrRemote: pr,
@ -380,8 +377,8 @@ export class StatusBarController implements Disposable {
commit,
commit.getGitUri(),
commit.lines[0].line,
this.container.config.statusBar.tooltipFormat,
this.container.config.defaultDateFormat,
configuration.get('statusBar.tooltipFormat'),
configuration.get('defaultDateFormat'),
{
autolinks: true,
cancellationToken: cancellationToken,

+ 2
- 1
src/trackers/gitLineTracker.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { Disposable, TextEditor } from 'vscode';
import { configuration } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitCommit } from '../git/models';
@ -100,7 +101,7 @@ export class GitLineTracker extends LineTracker {
},
})
private onDirtyIdleTriggered(e: DocumentDirtyIdleTriggerEvent<GitDocumentState>) {
const maxLines = this.container.config.advanced.blame.sizeThresholdAfterEdit;
const maxLines = configuration.get('advanced.blame.sizeThresholdAfterEdit');
if (maxLines > 0 && e.document.lineCount > maxLines) return;
this.resume();

+ 1
- 1
src/views/contributorsView.ts Zobrazit soubor

@ -78,7 +78,7 @@ export class ContributorsViewNode extends RepositoriesSubscribeableNode
const children = await child.getChildren();
// const all = this.view.container.config.views.contributors.showAllBranches;
// const all = configuration.get('views.contributors.showAllBranches');
// let ref: string | undefined;
// // If we aren't getting all branches, get the upstream of the current branch if there is one

+ 5
- 5
src/views/nodes/commitNode.ts Zobrazit soubor

@ -1,6 +1,6 @@
import { Command, MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { DiffWithPreviousCommandArgs } from '../../commands';
import { ViewFilesLayout } from '../../configuration';
import { configuration, ViewFilesLayout } from '../../configuration';
import { Colors, Commands } from '../../constants';
import { CommitFormatter } from '../../git/formatters';
import { GitBranch, GitCommit, GitRemote, GitRevisionReference, PullRequest } from '../../git/models';
@ -125,7 +125,7 @@ export class CommitNode extends ViewRefNode
async getTreeItem(): Promise<TreeItem> {
const label = CommitFormatter.fromTemplate(this.view.config.formats.commits.label, this.commit, {
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
getBranchAndTagTips: (sha: string) => this.getBranchAndTagTips?.(sha, { compact: true }),
messageTruncateAtNewLine: true,
});
@ -140,7 +140,7 @@ export class CommitNode extends ViewRefNode
}${this.unpublished ? '+unpublished' : ''}`;
item.description = CommitFormatter.fromTemplate(this.view.config.formats.commits.description, this.commit, {
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
getBranchAndTagTips: (sha: string) => this.getBranchAndTagTips?.(sha, { compact: true }),
messageTruncateAtNewLine: true,
});
@ -153,7 +153,7 @@ export class CommitNode extends ViewRefNode
: this.unpublished
? new ThemeIcon('arrow-up', new ThemeColor(Colors.UnpublishedCommitIconColor))
: this.view.config.avatars
? await this.commit.getAvatarUri({ defaultStyle: this.view.container.config.defaultGravatarsStyle })
? await this.commit.getAvatarUri({ defaultStyle: configuration.get('defaultGravatarsStyle') })
: new ThemeIcon('git-commit');
// item.tooltip = this.tooltip;
@ -243,7 +243,7 @@ export class CommitNode extends ViewRefNode
this.commit,
{
autolinkedIssuesOrPullRequests: autolinkedIssuesOrPullRequests,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
getBranchAndTagTips: this.getBranchAndTagTips,
markdown: true,
messageAutolinks: true,

+ 3
- 3
src/views/nodes/common.ts Zobrazit soubor

@ -1,6 +1,6 @@
import { Command, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { configuration } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitUri } from '../../git/gitUri';
import { View } from '../viewBase';
import { ContextValues, PageableViewNode, ViewNode } from './viewNode';
@ -150,7 +150,7 @@ export abstract class PagerNode extends ViewNode {
context?: Record<string, unknown>;
pageSize?: number;
getCount?: () => Promise<number | undefined>;
}, // protected readonly pageSize: number = Container.instance.config.views.pageItemLimit, // protected readonly countFn?: () => Promise<number | undefined>, // protected readonly context?: Record<string, unknown>, // protected readonly beforeLoadCallback?: (mode: 'all' | 'more') => void,
}, // protected readonly pageSize: number = configuration.get('views.pageItemLimit'), // protected readonly countFn?: () => Promise<number | undefined>, // protected readonly context?: Record<string, unknown>, // protected readonly beforeLoadCallback?: (mode: 'all' | 'more') => void,
) {
super(GitUri.unknown, view, parent);
}
@ -168,7 +168,7 @@ export abstract class PagerNode extends ViewNode {
loadMore() {
return this.view.loadMoreNodeChildren(
this.parent! as ViewNode & PageableViewNode,
this.options?.pageSize ?? Container.instance.config.views.pageItemLimit,
this.options?.pageSize ?? configuration.get('views.pageItemLimit'),
this.previousNode,
this.options?.context,
);

+ 3
- 2
src/views/nodes/contributorNode.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { MarkdownString, TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import { getPresenceDataUri } from '../../avatars';
import { configuration } from '../../configuration';
import { GlyphChars } from '../../constants';
import { GitUri } from '../../git/gitUri';
import { GitContributor, GitLog } from '../../git/models';
@ -98,9 +99,9 @@ export class ContributorNode extends ViewNode
let avatarUri;
let avatarMarkdown;
if (this.view.config.avatars) {
const size = this.view.container.config.hovers.avatarSize;
const size = configuration.get('hovers.avatarSize');
avatarUri = await this.contributor.getAvatarUri({
defaultStyle: this.view.container.config.defaultGravatarsStyle,
defaultStyle: configuration.get('defaultGravatarsStyle'),
size: size,
});

+ 3
- 2
src/views/nodes/contributorsNode.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { configuration } from '../../configuration';
import { GitUri } from '../../git/gitUri';
import { GitContributor, Repository } from '../../git/models';
import { gate } from '../../system/decorators/gate';
@ -36,7 +37,7 @@ export class ContributorsNode extends ViewNode
async getChildren(): Promise<ViewNode[]> {
if (this._children == null) {
const all = this.view.container.config.views.contributors.showAllBranches;
const all = configuration.get('views.contributors.showAllBranches');
let ref: string | undefined;
// If we aren't getting all branches, get the upstream of the current branch if there is one
@ -49,7 +50,7 @@ export class ContributorsNode extends ViewNode
} catch {}
}
const stats = this.view.container.config.views.contributors.showStatistics;
const stats = configuration.get('views.contributors.showStatistics');
const contributors = await this.repo.getContributors({ all: all, ref: ref, stats: stats });
if (contributors.length === 0) return [new MessageNode(this.view, this, 'No contributors could be found.')];

+ 5
- 4
src/views/nodes/fileRevisionAsCommitNode.ts Zobrazit soubor

@ -9,6 +9,7 @@ import {
Uri,
} from 'vscode';
import type { DiffWithPreviousCommandArgs } from '../../commands';
import { configuration } from '../../configuration';
import { Colors, Commands } from '../../constants';
import { CommitFormatter, StatusFileFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri';
@ -89,7 +90,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
const item = new TreeItem(
CommitFormatter.fromTemplate(this.view.config.formats.commits.label, this.commit, {
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
getBranchAndTagTips: (sha: string) => this._options.getBranchAndTagTips?.(sha, { compact: true }),
messageTruncateAtNewLine: true,
}),
@ -99,7 +100,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
item.contextValue = this.contextValue;
item.description = CommitFormatter.fromTemplate(this.view.config.formats.commits.description, this.commit, {
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
getBranchAndTagTips: (sha: string) => this._options.getBranchAndTagTips?.(sha, { compact: true }),
messageTruncateAtNewLine: true,
});
@ -109,7 +110,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
if (!this.commit.isUncommitted && this.view.config.avatars) {
item.iconPath = this._options.unpublished
? new ThemeIcon('arrow-up', new ThemeColor(Colors.UnpublishedCommitIconColor))
: await this.commit.getAvatarUri({ defaultStyle: this.view.container.config.defaultGravatarsStyle });
: await this.commit.getAvatarUri({ defaultStyle: configuration.get('defaultGravatarsStyle') });
}
if (item.iconPath == null) {
@ -232,7 +233,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
this.commit,
{
autolinkedIssuesOrPullRequests: autolinkedIssuesOrPullRequests,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
getBranchAndTagTips: this._options.getBranchAndTagTips,
markdown: true,
messageAutolinks: true,

+ 3
- 2
src/views/nodes/mergeConflictCurrentChangesNode.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { DiffWithCommandArgs } from '../../commands';
import { configuration } from '../../configuration';
import { Commands, CoreCommands, GlyphChars } from '../../constants';
import { CommitFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri';
@ -32,7 +33,7 @@ export class MergeConflictCurrentChangesNode extends ViewNode
commit != null ? ` (${GitReference.toString(commit, { expand: false, icon: false })})` : ' (HEAD)'
}`;
item.iconPath = this.view.config.avatars
? (await commit?.getAvatarUri({ defaultStyle: this.view.container.config.defaultGravatarsStyle })) ??
? (await commit?.getAvatarUri({ defaultStyle: configuration.get('defaultGravatarsStyle') })) ??
new ThemeIcon('diff')
: new ThemeIcon('diff');
@ -46,7 +47,7 @@ export class MergeConflictCurrentChangesNode extends ViewNode
commit,
{
avatarSize: 16,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
markdown: true,
// messageAutolinks: true,
messageIndent: 4,

+ 3
- 2
src/views/nodes/mergeConflictIncomingChangesNode.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { Command, MarkdownString, ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import type { DiffWithCommandArgs } from '../../commands';
import { configuration } from '../../configuration';
import { Commands, CoreCommands, GlyphChars } from '../../constants';
import { CommitFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri';
@ -37,7 +38,7 @@ export class MergeConflictIncomingChangesNode extends ViewNode
: ` (${GitReference.toString(this.status.HEAD, { expand: false, icon: false })})`
}`;
item.iconPath = this.view.config.avatars
? (await commit?.getAvatarUri({ defaultStyle: this.view.container.config.defaultGravatarsStyle })) ??
? (await commit?.getAvatarUri({ defaultStyle: configuration.get('defaultGravatarsStyle') })) ??
new ThemeIcon('diff')
: new ThemeIcon('diff');
@ -51,7 +52,7 @@ export class MergeConflictIncomingChangesNode extends ViewNode
commit,
{
avatarSize: 16,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
markdown: true,
// messageAutolinks: true,
messageIndent: 4,

+ 2
- 2
src/views/nodes/rebaseStatusNode.ts Zobrazit soubor

@ -1,6 +1,6 @@
import { Command, MarkdownString, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import type { DiffWithPreviousCommandArgs } from '../../commands';
import { ViewFilesLayout } from '../../configuration';
import { configuration, ViewFilesLayout } from '../../configuration';
import { Commands, CoreCommands } from '../../constants';
import { CommitFormatter } from '../../git/formatters';
import { GitUri } from '../../git/gitUri';
@ -217,7 +217,7 @@ export class RebaseCommitNode extends ViewRefNode
this.commit,
{
autolinkedIssuesOrPullRequests: autolinkedIssuesOrPullRequests,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
markdown: true,
messageAutolinks: true,
messageIndent: 4,

+ 2
- 3
src/views/nodes/resultsCommitsNode.ts Zobrazit soubor

@ -1,4 +1,5 @@
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { configuration } from '../../configuration';
import { GitUri } from '../../git/gitUri';
import type { GitLog } from '../../git/models';
import { gate } from '../../system/decorators/gate';
@ -168,9 +169,7 @@ export class ResultsCommitsNode
private _commitsQueryResults: Promise<CommitsQueryResults> | undefined;
private async getCommitsQueryResults() {
if (this._commitsQueryResults == null) {
this._commitsQueryResults = this._results.query(
this.limit ?? this.view.container.config.advanced.maxSearchItems,
);
this._commitsQueryResults = this._results.query(this.limit ?? configuration.get('advanced.maxSearchItems'));
const results = await this._commitsQueryResults;
this._hasMore = results.hasMore;

+ 4
- 3
src/views/nodes/stashNode.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ViewFilesLayout } from '../../config';
import { configuration } from '../../configuration';
import { CommitFormatter } from '../../git/formatters';
import { GitStashCommit, GitStashReference } from '../../git/models';
import { makeHierarchical } from '../../system/array';
@ -56,21 +57,21 @@ export class StashNode extends ViewRefNode
const item = new TreeItem(
CommitFormatter.fromTemplate(this.view.config.formats.stashes.label, this.commit, {
messageTruncateAtNewLine: true,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
}),
TreeItemCollapsibleState.Collapsed,
);
item.id = this.id;
item.description = CommitFormatter.fromTemplate(this.view.config.formats.stashes.description, this.commit, {
messageTruncateAtNewLine: true,
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
});
item.contextValue = ContextValues.Stash;
item.tooltip = CommitFormatter.fromTemplate(
`\${'On 'stashOnRef\n}\${ago} (\${date})\n\n\${message}`,
this.commit,
{
dateFormat: this.view.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
// messageAutolinks: true,
},
);

+ 3
- 3
src/views/repositoriesView.ts Zobrazit soubor

@ -114,12 +114,12 @@ export class RepositoriesView extends ViewBase
),
commands.registerCommand(
this.getQualifiedCommand('setAutoRefreshToOn'),
() => this.setAutoRefresh(this.container.config.views.repositories.autoRefresh, true),
() => this.setAutoRefresh(configuration.get('views.repositories.autoRefresh'), true),
this,
),
commands.registerCommand(
this.getQualifiedCommand('setAutoRefreshToOff'),
() => this.setAutoRefresh(this.container.config.views.repositories.autoRefresh, false),
() => this.setAutoRefresh(configuration.get('views.repositories.autoRefresh'), false),
this,
),
commands.registerCommand(
@ -282,7 +282,7 @@ export class RepositoriesView extends ViewBase
}
protected override onConfigurationChanged(e: ConfigurationChangeEvent) {
if (configuration.changed(e, `views.${this.configKey}.autoRefresh` as const)) {
void this.setAutoRefresh(this.container.config.views.repositories.autoRefresh);
void this.setAutoRefresh(configuration.get('views.repositories.autoRefresh'));
}
super.onConfigurationChanged(e);

+ 4
- 4
src/views/viewBase.ts Zobrazit soubor

@ -114,7 +114,7 @@ export abstract class ViewBase<
) {
this.disposables.push(once(container.onReady)(this.onReady, this));
if (this.container.debugging || this.container.config.debug) {
if (this.container.debugging || configuration.get('debug')) {
function addDebuggingInfo(item: TreeItem, node: ViewNode, parent: ViewNode | undefined) {
if (item.tooltip == null) {
item.tooltip = new MarkdownString(
@ -393,7 +393,7 @@ export abstract class ViewBase<
): Promise<ViewNode | undefined> {
const queue: (ViewNode | undefined)[] = [root, undefined];
const defaultPageSize = this.container.config.advanced.maxListItems;
const defaultPageSize = configuration.get('advanced.maxListItems');
let depth = 0;
let node: ViewNode | undefined;
@ -573,14 +573,14 @@ export abstract class ViewBase<
private _config: (ViewConfig & ViewsCommonConfig) | undefined;
get config(): ViewConfig & ViewsCommonConfig {
if (this._config == null) {
const cfg = { ...this.container.config.views };
const cfg = { ...configuration.get('views') };
for (const view of viewsConfigKeys) {
delete cfg[view];
}
this._config = {
...(cfg as ViewsCommonConfig),
...(this.container.config.views[this.configKey] as ViewConfig),
...(configuration.get('views')[this.configKey] as ViewConfig),
};
}

+ 2
- 1
src/vsls/vsls.ts Zobrazit soubor

@ -1,5 +1,6 @@
import { Disposable, extensions, workspace } from 'vscode';
import type { LiveShare, LiveShareExtension, SessionChangeEvent } from '../@types/vsls';
import { configuration } from '../configuration';
import { ContextKeys, Schemes } from '../constants';
import { Container } from '../container';
import { setContext } from '../context';
@ -96,7 +97,7 @@ export class VslsController implements Disposable {
case 1 /*Role.Host*/:
this.setReadonly(false);
void setContext(ContextKeys.Vsls, 'host');
if (this.container.config.liveshare.allowGuestAccess) {
if (configuration.get('liveshare.allowGuestAccess')) {
this._host = await VslsHostService.share(api, this.container);
}

+ 4
- 4
src/webviews/rebase/rebaseEditor.ts Zobrazit soubor

@ -566,7 +566,7 @@ async function parseRebaseTodo(
authors.set(name, {
author: name,
avatarUrl: (
await ontoCommit.getAvatarUri({ defaultStyle: container.config.defaultGravatarsStyle })
await ontoCommit.getAvatarUri({ defaultStyle: configuration.get('defaultGravatarsStyle') })
).toString(true),
email: email,
});
@ -575,7 +575,7 @@ async function parseRebaseTodo(
commits.push({
ref: ontoCommit.ref,
author: name,
date: ontoCommit.formatDate(container.config.defaultDateFormat),
date: ontoCommit.formatDate(configuration.get('defaultDateFormat')),
dateFromNow: ontoCommit.formatDateFromNow(),
message: ontoCommit.message || 'root',
});
@ -596,7 +596,7 @@ async function parseRebaseTodo(
authors.set(name, {
author: name,
avatarUrl: (
await commit.getAvatarUri({ defaultStyle: container.config.defaultGravatarsStyle })
await commit.getAvatarUri({ defaultStyle: configuration.get('defaultGravatarsStyle') })
).toString(true),
email: email,
});
@ -605,7 +605,7 @@ async function parseRebaseTodo(
commits.push({
ref: commit.ref,
author: name,
date: commit.formatDate(container.config.defaultDateFormat),
date: commit.formatDate(configuration.get('defaultDateFormat')),
dateFromNow: commit.formatDateFromNow(),
message: commit.message ?? commit.summary,
});

+ 3
- 3
src/webviews/webviewWithConfigBase.ts Zobrazit soubor

@ -162,10 +162,10 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
let includePullRequest = false;
switch (params.key) {
case configuration.name('currentLine.format'):
includePullRequest = this.container.config.currentLine.pullRequests.enabled;
includePullRequest = configuration.get('currentLine.pullRequests.enabled');
break;
case configuration.name('statusBar.format'):
includePullRequest = this.container.config.statusBar.pullRequests.enabled;
includePullRequest = configuration.get('statusBar.pullRequests.enabled');
break;
}
@ -191,7 +191,7 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
let preview;
try {
preview = CommitFormatter.fromTemplate(params.format, commit, {
dateFormat: this.container.config.defaultDateFormat,
dateFormat: configuration.get('defaultDateFormat'),
pullRequestOrRemote: pr,
messageTruncateAtNewLine: true,
});

+ 3
- 1
src/webviews/welcome/welcomeWebview.ts Zobrazit soubor

@ -1,3 +1,4 @@
import { configuration } from '../../configuration';
import { Commands } from '../../constants';
import type { Container } from '../../container';
import { WebviewWithConfigBase } from '../webviewWithConfigBase';
@ -17,7 +18,8 @@ export class WelcomeWebview extends WebviewWithConfigBase {
protected override includeBootstrap(): State {
return {
config: this.container.config,
// Make sure to get the raw config, not from the container which has the modes mixed in
config: configuration.getAll(true),
};
}
}

||||||
x
 
000:0
Načítá se…
Zrušit
Uložit