Explorar el Código

Adds more logging for file watching issues

If repo lacks watching, pretend change checks are true if unknown change
main
Eric Amodio hace 4 años
padre
commit
cbc742e3e9
Se han modificado 5 ficheros con 55 adiciones y 13 borrados
  1. +2
    -2
      src/extension.ts
  2. +37
    -8
      src/git/models/repository.ts
  3. +2
    -2
      src/hovers/hovers.ts
  4. +14
    -0
      src/logger.ts
  5. +0
    -1
      src/quickpicks/quickPicksItems.ts

+ 2
- 2
src/extension.ts Ver fichero

@ -10,7 +10,7 @@ import { Container } from './container';
import { Git, GitCommit } from './git/git';
import { GitService } from './git/gitService';
import { GitUri } from './git/gitUri';
import { Logger, TraceLevel } from './logger';
import { Logger } from './logger';
import { Messages } from './messages';
import { Strings, Versions } from './system';
import { ViewNode } from './views/nodes';
@ -69,7 +69,7 @@ export async function activate(context: ExtensionContext): Promise
context.globalState.get<string>(GlobalState.Deprecated_Version) ??
syncedVersion;
if (Logger.level === TraceLevel.Debug || Logger.isDebugging) {
if (Logger.willLog('debug')) {
Logger.debug(
`GitLens (v${gitlensVersion}): syncedVersion=${syncedVersion}, previousVersion=${previousVersion}, ${
SyncedState.WelcomeViewVisible

+ 37
- 8
src/git/models/repository.ts Ver fichero

@ -47,18 +47,37 @@ export class RepositoryChangeEvent {
constructor(public readonly repository?: Repository, public readonly changes: RepositoryChange[] = []) {}
changed(change: RepositoryChange, only: boolean = false) {
if (only) return this.changes.length === 1 && this.changes[0] === change;
if (only) {
if (this.changes.length !== 1) return false;
if (this.changes[0] === change) return true;
if (this.repository?.supportsChangeEvents === false && this.changes[0] === RepositoryChange.Unknown) {
switch (change) {
case RepositoryChange.Closed:
case RepositoryChange.Starred:
return false;
default:
return true;
}
}
return this.changes.includes(change);
return false;
}
// const changed = this.changes.includes(change);
// if (changed) return true;
if (this.changes.includes(change)) return true;
// if (change === RepositoryChange.Repository) {
// return this.changes.includes(RepositoryChange.Stashes);
// }
if (this.repository?.supportsChangeEvents === false && this.changes.includes(RepositoryChange.Unknown)) {
switch (change) {
case RepositoryChange.Closed:
case RepositoryChange.Ignores:
case RepositoryChange.Starred:
return false;
default:
return true;
}
}
// return false;
return false;
}
}
@ -159,6 +178,16 @@ export class Repository implements Disposable {
configuration.onDidChange(this.onConfigurationChanged, this),
);
this.onConfigurationChanged(configuration.initializingChangeEvent);
if (!this.supportsChangeEvents && Logger.willLog('debug')) {
Logger.debug(
`Repository[${this.name}(${
this.id
})] doesn't support file watching; path=${path}, workspaceFolders=${workspace.workspaceFolders
?.map(wf => wf.uri.fsPath)
.join('; ')}`,
);
}
}
dispose() {

+ 2
- 2
src/hovers/hovers.ts Ver fichero

@ -14,7 +14,7 @@ import {
GitRevision,
} from '../git/git';
import { GitUri } from '../git/gitUri';
import { Logger, TraceLevel } from '../logger';
import { Logger } from '../logger';
import { Iterables, Promises, Strings } from '../system';
export namespace Hovers {
@ -258,7 +258,7 @@ export namespace Hovers {
timeout: timeout,
});
if (autolinks != null && (Logger.level === TraceLevel.Debug || Logger.isDebugging)) {
if (autolinks != null && Logger.willLog('debug')) {
// If there are any issues/PRs that timed out, log it
const count = Iterables.count(autolinks.values(), pr => pr instanceof Promises.CancellationError);
if (count !== 0) {

+ 14
- 0
src/logger.ts Ver fichero

@ -196,6 +196,20 @@ export class Logger {
}
}
static willLog(type: 'debug' | 'error' | 'log' | 'warn'): boolean {
switch (type) {
case 'debug':
return this.level === TraceLevel.Debug || Logger.isDebugging;
case 'error':
case 'warn':
return this.level !== TraceLevel.Silent || Logger.isDebugging;
case 'log':
return this.level === TraceLevel.Verbose || this.level === TraceLevel.Debug || Logger.isDebugging;
default:
return false;
}
}
static showOutputChannel() {
if (this.output == null) return;

+ 0
- 1
src/quickpicks/quickPicksItems.ts Ver fichero

@ -6,7 +6,6 @@ import { GitReference, GitRevisionReference, GitStashCommit, SearchPattern } fro
import { Keys } from '../keyboard';
declare module 'vscode' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface QuickPickItem {
onDidSelect?(): void;
onDidPressKey?(key: Keys): Promise<void>;

Cargando…
Cancelar
Guardar