Skip to content

Commit 0fd9a00

Browse files
authored
SCM - limit logging to smoke tests only (#214865)
* SCM - smoke test fix + more logging * SCM - limit logging to smoke tests only
1 parent fc8e4df commit 0fd9a00

File tree

2 files changed

+47
-20
lines changed

2 files changed

+47
-20
lines changed

src/vs/workbench/api/browser/mainThreadSCM.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { ITextModelContentProvider, ITextModelService } from 'vs/editor/common/s
2828
import { Schemas } from 'vs/base/common/network';
2929
import { ITextModel } from 'vs/editor/common/model';
3030
import { ILogService } from 'vs/platform/log/common/log';
31+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
3132

3233
function getIconFromIconDto(iconDto?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
3334
if (iconDto === undefined) {
@@ -272,6 +273,7 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
272273
private readonly _quickDiffService: IQuickDiffService,
273274
private readonly _uriIdentService: IUriIdentityService,
274275
private readonly _workspaceContextService: IWorkspaceContextService,
276+
private readonly _environmentService: IWorkbenchEnvironmentService,
275277
private readonly _logService: ILogService
276278
) {
277279
if (_rootUri) {
@@ -297,7 +299,9 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
297299
}
298300

299301
if (typeof features.statusBarCommands !== 'undefined') {
300-
this._logService.info('MainThreadSCMProvider#updateSourceControl:', features.statusBarCommands.map(c => c.title).join(', '));
302+
if (this._environmentService.enableSmokeTestDriver) {
303+
this._logService.info(`MainThreadSCMProvider#updateSourceControl (${this._id}): ${features.statusBarCommands.map(c => c.title).join(', ')}`);
304+
}
301305
this._statusBarCommands.set(features.statusBarCommands, undefined);
302306
}
303307

@@ -479,6 +483,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
479483
@IQuickDiffService private readonly quickDiffService: IQuickDiffService,
480484
@IUriIdentityService private readonly _uriIdentService: IUriIdentityService,
481485
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
486+
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
482487
@ILogService private readonly logService: ILogService
483488
) {
484489
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostSCM);
@@ -500,7 +505,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
500505
this._repositoryBarriers.set(handle, new Barrier());
501506

502507
const inputBoxTextModelRef = await this.textModelService.createModelReference(URI.revive(inputBoxDocumentUri));
503-
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri ? URI.revive(rootUri) : undefined, inputBoxTextModelRef.object.textEditorModel, this.quickDiffService, this._uriIdentService, this.workspaceContextService, this.logService);
508+
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri ? URI.revive(rootUri) : undefined, inputBoxTextModelRef.object.textEditorModel, this.quickDiffService, this._uriIdentService, this.workspaceContextService, this.environmentService, this.logService);
504509
const repository = this.scmService.registerSCMProvider(provider);
505510
this._repositories.set(handle, repository);
506511

src/vs/workbench/contrib/scm/browser/activity.ts

+40-18
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { derivedObservableWithCache, latestChangedValue, observableFromEventOpts
2828
import { Command } from 'vs/editor/common/languages';
2929
import { ISCMHistoryItemGroup } from 'vs/workbench/contrib/scm/common/history';
3030
import { ILogService } from 'vs/platform/log/common/log';
31+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
3132

3233
export class SCMActiveRepositoryController extends Disposable implements IWorkbenchContribution {
3334
private readonly _countBadgeConfig = observableConfigValue<'all' | 'focused' | 'off'>('scm.countBadge', 'all', this.configurationService);
@@ -49,18 +50,28 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
4950
private readonly _activeEditorRepository = derivedObservableWithCache<ISCMRepository | undefined>(this, (reader, lastValue) => {
5051
const activeResource = EditorResourceAccessor.getOriginalUri(this._activeEditor.read(reader));
5152
if (!activeResource) {
53+
if (this.environmentService.enableSmokeTestDriver) {
54+
this.logService.info('SCMActiveRepositoryController (activeEditorRepository derived): no activeResource');
55+
}
5256
return lastValue;
5357
}
5458

5559
const repository = this.scmService.getRepository(activeResource);
5660
if (!repository) {
61+
if (this.environmentService.enableSmokeTestDriver) {
62+
this.logService.info(`SCMActiveRepositoryController (activeEditorRepository derived): no repository for '${activeResource.toString()}'`);
63+
}
5764
return lastValue;
5865
}
5966

6067
return Object.create(repository);
6168
});
6269

63-
private readonly _activeRepository = latestChangedValue(this._focusedRepository, this._activeEditorRepository);
70+
/**
71+
* The focused repository takes precedence over the active editor repository when the observable
72+
* values are updated in the same transaction (or during the initial read of the observable value).
73+
*/
74+
private readonly _activeRepository = latestChangedValue(this._activeEditorRepository, this._focusedRepository);
6475

6576
private readonly _countBadgeRepositories = derived(reader => {
6677
switch (this._countBadgeConfig.read(reader)) {
@@ -104,7 +115,8 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
104115
@ISCMService private readonly scmService: ISCMService,
105116
@ISCMViewService private readonly scmViewService: ISCMViewService,
106117
@IStatusbarService private readonly statusbarService: IStatusbarService,
107-
@ITitleService private readonly titleService: ITitleService
118+
@ITitleService private readonly titleService: ITitleService,
119+
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
108120
) {
109121
super();
110122

@@ -116,30 +128,38 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
116128
{ name: 'activeRepositoryBranchName', contextKey: ActiveRepositoryContextKeys.ActiveRepositoryBranchName.key, }
117129
]);
118130

119-
this._register(autorunWithStore((reader, store) => {
120-
this._updateActivityCountBadge(this._countBadge.read(reader), store);
121-
}));
131+
if (this.environmentService.enableSmokeTestDriver) {
132+
this._register(autorun(reader => {
133+
const repository = this._focusedRepository.read(reader);
134+
const commands = repository?.provider.statusBarCommands.read(reader);
122135

123-
this._register(autorun(reader => {
124-
const repository = this._focusedRepository.read(reader);
125-
const commands = repository?.provider.statusBarCommands.read(reader) ?? [];
136+
this.logService.info('SCMActiveRepositoryController (focusedRepository):', repository?.id ?? 'no id');
137+
this.logService.info('SCMActiveRepositoryController (focusedRepository):', commands ? commands.map(c => c.title).join(', ') : 'no commands');
138+
}));
126139

127-
this.logService.info('SCMActiveRepositoryController (focusedRepository):', commands.map(c => c.title).join(', '));
128-
}));
140+
this._register(autorun(reader => {
141+
const repository = this._activeEditorRepository.read(reader);
142+
const commands = repository?.provider.statusBarCommands.read(reader);
129143

130-
this._register(autorun(reader => {
131-
const repository = this._activeEditorRepository.read(reader);
132-
const commands = repository?.provider.statusBarCommands.read(reader) ?? [];
144+
this.logService.info('SCMActiveRepositoryController (activeEditorRepository):', repository?.id ?? 'no id');
145+
this.logService.info('SCMActiveRepositoryController (activeEditorRepository):', commands ? commands.map(c => c.title).join(', ') : 'no commands');
146+
}));
147+
}
133148

134-
this.logService.info('SCMActiveRepositoryController (activeEditorRepository):', commands.map(c => c.title).join(', '));
149+
this._register(autorunWithStore((reader, store) => {
150+
this._updateActivityCountBadge(this._countBadge.read(reader), store);
135151
}));
136152

137153
this._register(autorunWithStore((reader, store) => {
138154
const repository = this._activeRepository.read(reader);
139-
const commands = repository?.provider.statusBarCommands.read(reader) ?? [];
140-
this.logService.info('SCMActiveRepositoryController (status bar):', commands.map(c => c.title).join(', '));
155+
const commands = repository?.provider.statusBarCommands.read(reader);
141156

142-
this._updateStatusBar(repository, commands, store);
157+
if (this.environmentService.enableSmokeTestDriver) {
158+
this.logService.info('SCMActiveRepositoryController (status bar):', repository?.id ?? 'no id');
159+
this.logService.info('SCMActiveRepositoryController (status bar):', commands ? commands.map(c => c.title).join(', ') : 'no commands');
160+
}
161+
162+
this._updateStatusBar(repository, commands ?? [], store);
143163
}));
144164

145165
this._register(autorun(reader => {
@@ -165,7 +185,9 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
165185

166186
private _updateStatusBar(repository: ISCMRepository | undefined, commands: readonly Command[], store: DisposableStore): void {
167187
if (!repository) {
168-
this.logService.info('SCMActiveRepositoryController (status bar): repository is undefined');
188+
if (this.environmentService.enableSmokeTestDriver) {
189+
this.logService.info('SCMActiveRepositoryController (status bar): repository is undefined');
190+
}
169191
return;
170192
}
171193

0 commit comments

Comments
 (0)