提交 9c2cc80f 编写于 作者: S Sandeep Somavarapu

Move getHashedRemotesFromUri to IWorkspaceStatsService

上级 994e1315
......@@ -859,6 +859,10 @@ class WorkspaceStatsService implements IWorkspaceStatsService {
return undefined;
}
getHashedRemotesFromUri(workspaceUri: URI, stripEndingDotGit?: boolean): Promise<string[]> {
return Promise.resolve([]);
}
}
registerSingleton(IWorkspaceStatsService, WorkspaceStatsService);
......
......@@ -29,7 +29,6 @@ import { flatten, distinct, shuffle, coalesce } from 'vs/base/common/arrays';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { guessMimeTypes, MIME_UNKNOWN } from 'vs/base/common/mime';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { getHashedRemotesFromUri } from 'vs/workbench/contrib/stats/electron-browser/workspaceStats';
import { IRequestService, asJson } from 'vs/platform/request/common/request';
import { isNumber } from 'vs/base/common/types';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
......@@ -42,9 +41,9 @@ import { IExperimentService, ExperimentActionType, ExperimentState } from 'vs/wo
import { CancellationToken } from 'vs/base/common/cancellation';
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
import { extname } from 'vs/base/common/resources';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IExeBasedExtensionTip } from 'vs/platform/product/common/product';
import { timeout } from 'vs/base/common/async';
import { IWorkspaceStatsService } from 'vs/workbench/contrib/stats/common/workspaceStats';
const milliSecondsInADay = 1000 * 60 * 60 * 24;
const choiceNever = localize('neverShowAgain', "Don't Show Again");
......@@ -109,7 +108,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
@IExtensionsWorkbenchService private readonly extensionWorkbenchService: IExtensionsWorkbenchService,
@IExperimentService private readonly experimentService: IExperimentService,
@ITextFileService private readonly textFileService: ITextFileService
@IWorkspaceStatsService private readonly workspaceStatsService: IWorkspaceStatsService
) {
super();
......@@ -1078,7 +1077,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
const storageKey = 'extensionsAssistant/dynamicWorkspaceRecommendations';
const workspaceUri = this.contextService.getWorkspace().folders[0].uri;
return Promise.all([getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, false), getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, true)]).then(([hashedRemotes1, hashedRemotes2]) => {
return Promise.all([this.workspaceStatsService.getHashedRemotesFromUri(workspaceUri, false), this.workspaceStatsService.getHashedRemotesFromUri(workspaceUri, true)]).then(([hashedRemotes1, hashedRemotes2]) => {
const hashedRemotes = (hashedRemotes1 || []).concat(hashedRemotes2 || []);
if (!hashedRemotes.length) {
return undefined;
......
......@@ -5,6 +5,7 @@
import { WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { URI } from 'vs/base/common/uri';
export type Tags = { [index: string]: boolean | number | string | undefined };
......@@ -20,4 +21,6 @@ export interface IWorkspaceStatsService {
* on the folder uri or workspace configuration, not time-based, and undefined for empty workspaces.
*/
getTelemetryWorkspaceId(workspace: IWorkspace, state: WorkbenchState): string | undefined;
getHashedRemotesFromUri(workspaceUri: URI, stripEndingDotGit?: boolean): Promise<string[]>;
}
......@@ -136,20 +136,6 @@ export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: bool
});
}
export function getHashedRemotesFromUri(workspaceUri: URI, fileService: IFileService, textFileService: ITextFileService, stripEndingDotGit: boolean = false): Promise<string[]> {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
return fileService.exists(uri).then(exists => {
if (!exists) {
return [];
}
return textFileService.read(uri, { acceptTextOnly: true }).then(
content => getHashedRemotesFromConfig(content.value, stripEndingDotGit),
err => [] // ignore missing or binary file
);
});
}
export class WorkspaceStats implements IWorkbenchContribution {
constructor(
......@@ -230,7 +216,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
private reportRemotes(workspaceUris: URI[]): void {
Promise.all<string[]>(workspaceUris.map(workspaceUri => {
return getHashedRemotesFromUri(workspaceUri, this.fileService, this.textFileService, true);
return this.workspaceStatsService.getHashedRemotesFromUri(workspaceUri, true);
})).then(hashedRemotes => {
/* __GDPR__
"workspace.hashedRemotes" : {
......
......@@ -20,6 +20,7 @@ import Severity from 'vs/base/common/severity';
import { joinPath } from 'vs/base/common/resources';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkspaceStatsService, Tags } from 'vs/workbench/contrib/stats/common/workspaceStats';
import { getHashedRemotesFromConfig } from 'vs/workbench/contrib/stats/electron-browser/workspaceStats';
const DISABLE_WORKSPACE_PROMPT_KEY = 'workspaces.dontPromptToOpen';
......@@ -136,6 +137,20 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
return workspaceId;
}
getHashedRemotesFromUri(workspaceUri: URI, stripEndingDotGit: boolean = false): Promise<string[]> {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
return this.fileService.exists(uri).then(exists => {
if (!exists) {
return [];
}
return this.textFileService.read(uri, { acceptTextOnly: true }).then(
content => getHashedRemotesFromConfig(content.value, stripEndingDotGit),
err => [] // ignore missing or binary file
);
});
}
/* __GDPR__FRAGMENT__
"WorkspaceTags" : {
"workbench.filesToOpenOrCreate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册