mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
model -> repository
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import { workspace, Disposable } from 'vscode';
|
||||
import { GitErrorCodes } from './git';
|
||||
import { Model } from './model';
|
||||
import { Repository } from './repository';
|
||||
import { throttle } from './decorators';
|
||||
|
||||
export class AutoFetcher {
|
||||
@@ -16,7 +16,7 @@ export class AutoFetcher {
|
||||
private disposables: Disposable[] = [];
|
||||
private timer: NodeJS.Timer;
|
||||
|
||||
constructor(private model: Model) {
|
||||
constructor(private model: Repository) {
|
||||
workspace.onDidChangeConfiguration(this.onConfiguration, this, this.disposables);
|
||||
this.onConfiguration();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { Uri, commands, scm, Disposable, window, workspace, QuickPickItem, OutputChannel, Range, WorkspaceEdit, Position, LineChange, SourceControlResourceState, TextDocumentShowOptions, ViewColumn } from 'vscode';
|
||||
import { Ref, RefType, Git, GitErrorCodes, Branch } from './git';
|
||||
import { Model, Resource, Status, CommitOptions, WorkingTreeGroup, IndexGroup, MergeGroup } from './model';
|
||||
import { Repository, Resource, Status, CommitOptions, WorkingTreeGroup, IndexGroup, MergeGroup } from './repository';
|
||||
import { ModelRegistry } from './modelRegistry';
|
||||
import { toGitUri, fromGitUri } from './uri';
|
||||
import { applyLineChanges, intersectDiffWithRange, toLineRanges, invertLineChange } from './staging';
|
||||
@@ -27,7 +27,7 @@ class CheckoutItem implements QuickPickItem {
|
||||
|
||||
constructor(protected ref: Ref) { }
|
||||
|
||||
async run(model: Model): Promise<void> {
|
||||
async run(model: Repository): Promise<void> {
|
||||
const ref = this.treeish;
|
||||
|
||||
if (!ref) {
|
||||
@@ -70,7 +70,7 @@ class BranchDeleteItem implements QuickPickItem {
|
||||
|
||||
constructor(private ref: Ref) { }
|
||||
|
||||
async run(model: Model, force?: boolean): Promise<void> {
|
||||
async run(model: Repository, force?: boolean): Promise<void> {
|
||||
if (!this.branchName) {
|
||||
return;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class MergeItem implements QuickPickItem {
|
||||
|
||||
constructor(protected ref: Ref) { }
|
||||
|
||||
async run(model: Model): Promise<void> {
|
||||
async run(model: Repository): Promise<void> {
|
||||
await model.merge(this.ref.name! || this.ref.commit!);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class CreateBranchItem implements QuickPickItem {
|
||||
get label(): string { return localize('create branch', '$(plus) Create new branch'); }
|
||||
get description(): string { return ''; }
|
||||
|
||||
async run(model: Model): Promise<void> {
|
||||
async run(model: Repository): Promise<void> {
|
||||
await commands.executeCommand('git.branch');
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ export class CommandCenter {
|
||||
});
|
||||
}
|
||||
|
||||
private groupByModel(resources: Uri[]): [Model | undefined, Uri[]][] {
|
||||
private groupByModel(resources: Uri[]): [Repository | undefined, Uri[]][] {
|
||||
return resources.reduce((result, resource) => {
|
||||
const model = this.modelRegistry.getModel(resource);
|
||||
const pair = result.filter(p => p[0] === model)[0];
|
||||
@@ -157,20 +157,20 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
return result;
|
||||
}, [] as [Model | undefined, Uri[]][]);
|
||||
}, [] as [Repository | undefined, Uri[]][]);
|
||||
}
|
||||
|
||||
@command('git.refresh', { model: true })
|
||||
async refresh(model: Model): Promise<void> {
|
||||
async refresh(model: Repository): Promise<void> {
|
||||
await model.status();
|
||||
}
|
||||
|
||||
@command('git.openResource', { model: true })
|
||||
async openResource(model: Model, resource: Resource): Promise<void> {
|
||||
async openResource(model: Repository, resource: Resource): Promise<void> {
|
||||
await this._openResource(model, resource);
|
||||
}
|
||||
|
||||
private async _openResource(model: Model, resource: Resource, preview?: boolean): Promise<void> {
|
||||
private async _openResource(model: Repository, resource: Resource, preview?: boolean): Promise<void> {
|
||||
const left = this.getLeftResource(resource);
|
||||
const right = this.getRightResource(model, resource);
|
||||
const title = this.getTitle(resource);
|
||||
@@ -216,7 +216,7 @@ export class CommandCenter {
|
||||
}
|
||||
}
|
||||
|
||||
private getRightResource(model: Model, resource: Resource): Uri | undefined {
|
||||
private getRightResource(model: Repository, resource: Resource): Uri | undefined {
|
||||
switch (resource.type) {
|
||||
case Status.INDEX_MODIFIED:
|
||||
case Status.INDEX_ADDED:
|
||||
@@ -322,7 +322,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.openFile', { model: true })
|
||||
async openFile(model: Model, arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
async openFile(model: Repository, arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
let uris: Uri[] | undefined;
|
||||
|
||||
if (arg instanceof Uri) {
|
||||
@@ -372,7 +372,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.openHEADFile', { model: true })
|
||||
async openHEADFile(model: Model, arg?: Resource | Uri): Promise<void> {
|
||||
async openHEADFile(model: Repository, arg?: Resource | Uri): Promise<void> {
|
||||
let resource: Resource | undefined = undefined;
|
||||
|
||||
if (arg instanceof Resource) {
|
||||
@@ -398,7 +398,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.openChange', { model: true })
|
||||
async openChange(model: Model, arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
async openChange(model: Repository, arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
let resources: Resource[] | undefined = undefined;
|
||||
|
||||
if (arg instanceof Uri) {
|
||||
@@ -462,13 +462,13 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.stageAll', { model: true })
|
||||
async stageAll(model: Model): Promise<void> {
|
||||
async stageAll(model: Repository): Promise<void> {
|
||||
return await model.add();
|
||||
}
|
||||
|
||||
// TODO@Joao does this command really receive a model?
|
||||
@command('git.stageSelectedRanges', { model: true, diff: true })
|
||||
async stageSelectedRanges(model: Model, diffs: LineChange[]): Promise<void> {
|
||||
async stageSelectedRanges(model: Repository, diffs: LineChange[]): Promise<void> {
|
||||
const textEditor = window.activeTextEditor;
|
||||
|
||||
if (!textEditor) {
|
||||
@@ -500,7 +500,7 @@ export class CommandCenter {
|
||||
|
||||
// TODO@Joao does this command really receive a model?
|
||||
@command('git.revertSelectedRanges', { model: true, diff: true })
|
||||
async revertSelectedRanges(model: Model, diffs: LineChange[]): Promise<void> {
|
||||
async revertSelectedRanges(model: Repository, diffs: LineChange[]): Promise<void> {
|
||||
const textEditor = window.activeTextEditor;
|
||||
|
||||
if (!textEditor) {
|
||||
@@ -545,7 +545,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.unstage', { model: true })
|
||||
async unstage(model: Model, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
async unstage(model: Repository, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
|
||||
const resource = this.getSCMResource();
|
||||
|
||||
@@ -569,13 +569,13 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.unstageAll', { model: true })
|
||||
async unstageAll(model: Model): Promise<void> {
|
||||
async unstageAll(model: Repository): Promise<void> {
|
||||
return await model.revertFiles();
|
||||
}
|
||||
|
||||
// TODO@Joao does this command really receive a model?
|
||||
@command('git.unstageSelectedRanges', { model: true, diff: true })
|
||||
async unstageSelectedRanges(model: Model, diffs: LineChange[]): Promise<void> {
|
||||
async unstageSelectedRanges(model: Repository, diffs: LineChange[]): Promise<void> {
|
||||
const textEditor = window.activeTextEditor;
|
||||
|
||||
if (!textEditor) {
|
||||
@@ -613,7 +613,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.clean', { model: true })
|
||||
async clean(model: Model, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
async clean(model: Repository, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
|
||||
const resource = this.getSCMResource();
|
||||
|
||||
@@ -660,7 +660,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.cleanAll', { model: true })
|
||||
async cleanAll(model: Model): Promise<void> {
|
||||
async cleanAll(model: Repository): Promise<void> {
|
||||
const config = workspace.getConfiguration('git');
|
||||
let scope = config.get<string>('discardAllScope') || 'prompt';
|
||||
let resources = model.workingTreeGroup.resources;
|
||||
@@ -712,7 +712,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
private async smartCommit(
|
||||
model: Model,
|
||||
model: Repository,
|
||||
getCommitMessage: () => Promise<string | undefined>,
|
||||
opts?: CommitOptions
|
||||
): Promise<boolean> {
|
||||
@@ -767,7 +767,7 @@ export class CommandCenter {
|
||||
return true;
|
||||
}
|
||||
|
||||
private async commitWithAnyInput(model: Model, opts?: CommitOptions): Promise<void> {
|
||||
private async commitWithAnyInput(model: Repository, opts?: CommitOptions): Promise<void> {
|
||||
const message = scm.inputBox.value;
|
||||
const getCommitMessage = async () => {
|
||||
if (message) {
|
||||
@@ -789,12 +789,12 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.commit', { model: true })
|
||||
async commit(model: Model): Promise<void> {
|
||||
async commit(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model);
|
||||
}
|
||||
|
||||
@command('git.commitWithInput', { model: true })
|
||||
async commitWithInput(model: Model): Promise<void> {
|
||||
async commitWithInput(model: Repository): Promise<void> {
|
||||
if (!scm.inputBox.value) {
|
||||
return;
|
||||
}
|
||||
@@ -807,37 +807,37 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.commitStaged', { model: true })
|
||||
async commitStaged(model: Model): Promise<void> {
|
||||
async commitStaged(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model, { all: false });
|
||||
}
|
||||
|
||||
@command('git.commitStagedSigned', { model: true })
|
||||
async commitStagedSigned(model: Model): Promise<void> {
|
||||
async commitStagedSigned(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model, { all: false, signoff: true });
|
||||
}
|
||||
|
||||
@command('git.commitStagedAmend', { model: true })
|
||||
async commitStagedAmend(model: Model): Promise<void> {
|
||||
async commitStagedAmend(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model, { all: false, amend: true });
|
||||
}
|
||||
|
||||
@command('git.commitAll', { model: true })
|
||||
async commitAll(model: Model): Promise<void> {
|
||||
async commitAll(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model, { all: true });
|
||||
}
|
||||
|
||||
@command('git.commitAllSigned', { model: true })
|
||||
async commitAllSigned(model: Model): Promise<void> {
|
||||
async commitAllSigned(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model, { all: true, signoff: true });
|
||||
}
|
||||
|
||||
@command('git.commitAllAmend', { model: true })
|
||||
async commitAllAmend(model: Model): Promise<void> {
|
||||
async commitAllAmend(model: Repository): Promise<void> {
|
||||
await this.commitWithAnyInput(model, { all: true, amend: true });
|
||||
}
|
||||
|
||||
@command('git.undoCommit', { model: true })
|
||||
async undoCommit(model: Model): Promise<void> {
|
||||
async undoCommit(model: Repository): Promise<void> {
|
||||
const HEAD = model.HEAD;
|
||||
|
||||
if (!HEAD || !HEAD.commit) {
|
||||
@@ -850,7 +850,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.checkout', { model: true })
|
||||
async checkout(model: Model, treeish: string): Promise<void> {
|
||||
async checkout(model: Repository, treeish: string): Promise<void> {
|
||||
if (typeof treeish === 'string') {
|
||||
return await model.checkout(treeish);
|
||||
}
|
||||
@@ -883,7 +883,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.branch', { model: true })
|
||||
async branch(model: Model): Promise<void> {
|
||||
async branch(model: Repository): Promise<void> {
|
||||
const result = await window.showInputBox({
|
||||
placeHolder: localize('branch name', "Branch name"),
|
||||
prompt: localize('provide branch name', "Please provide a branch name"),
|
||||
@@ -899,7 +899,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.deleteBranch', { model: true })
|
||||
async deleteBranch(model: Model, name: string, force?: boolean): Promise<void> {
|
||||
async deleteBranch(model: Repository, name: string, force?: boolean): Promise<void> {
|
||||
let run: (force?: boolean) => Promise<void>;
|
||||
if (typeof name === 'string') {
|
||||
run = force => model.deleteBranch(name, force);
|
||||
@@ -936,7 +936,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.merge', { model: true })
|
||||
async merge(model: Model): Promise<void> {
|
||||
async merge(model: Repository): Promise<void> {
|
||||
const config = workspace.getConfiguration('git');
|
||||
const checkoutType = config.get<string>('checkoutType') || 'all';
|
||||
const includeRemotes = checkoutType === 'all' || checkoutType === 'remote';
|
||||
@@ -970,7 +970,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.createTag', { model: true })
|
||||
async createTag(model: Model): Promise<void> {
|
||||
async createTag(model: Repository): Promise<void> {
|
||||
const inputTagName = await window.showInputBox({
|
||||
placeHolder: localize('tag name', "Tag name"),
|
||||
prompt: localize('provide tag name', "Please provide a tag name"),
|
||||
@@ -993,7 +993,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.pullFrom', { model: true })
|
||||
async pullFrom(model: Model): Promise<void> {
|
||||
async pullFrom(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1023,7 +1023,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.pull', { model: true })
|
||||
async pull(model: Model): Promise<void> {
|
||||
async pull(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1035,7 +1035,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.pullRebase', { model: true })
|
||||
async pullRebase(model: Model): Promise<void> {
|
||||
async pullRebase(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1047,7 +1047,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.push', { model: true })
|
||||
async push(model: Model): Promise<void> {
|
||||
async push(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1059,7 +1059,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.pushWithTags', { model: true })
|
||||
async pushWithTags(model: Model): Promise<void> {
|
||||
async pushWithTags(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1073,7 +1073,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.pushTo', { model: true })
|
||||
async pushTo(model: Model): Promise<void> {
|
||||
async pushTo(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1099,7 +1099,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.sync', { model: true })
|
||||
async sync(model: Model): Promise<void> {
|
||||
async sync(model: Repository): Promise<void> {
|
||||
const HEAD = model.HEAD;
|
||||
|
||||
if (!HEAD || !HEAD.upstream) {
|
||||
@@ -1126,7 +1126,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.publish', { model: true })
|
||||
async publish(model: Model): Promise<void> {
|
||||
async publish(model: Repository): Promise<void> {
|
||||
const remotes = model.remotes;
|
||||
|
||||
if (remotes.length === 0) {
|
||||
@@ -1152,7 +1152,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.ignore', { model: true })
|
||||
async ignore(model: Model, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
async ignore(model: Repository, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
if (resourceStates.length === 0 || !(resourceStates[0].resourceUri instanceof Uri)) {
|
||||
const uri = window.activeTextEditor && window.activeTextEditor.document.uri;
|
||||
|
||||
@@ -1175,7 +1175,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.stash', { model: true })
|
||||
async stash(model: Model): Promise<void> {
|
||||
async stash(model: Repository): Promise<void> {
|
||||
if (model.workingTreeGroup.resources.length === 0) {
|
||||
window.showInformationMessage(localize('no changes stash', "There are no changes to stash."));
|
||||
return;
|
||||
@@ -1194,7 +1194,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.stashPop', { model: true })
|
||||
async stashPop(model: Model): Promise<void> {
|
||||
async stashPop(model: Repository): Promise<void> {
|
||||
const stashes = await model.getStashes();
|
||||
|
||||
if (stashes.length === 0) {
|
||||
@@ -1214,7 +1214,7 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
@command('git.stashPopLatest', { model: true })
|
||||
async stashPopLatest(model: Model): Promise<void> {
|
||||
async stashPopLatest(model: Repository): Promise<void> {
|
||||
const stashes = await model.getStashes();
|
||||
|
||||
if (stashes.length === 0) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { workspace, Uri, Disposable, Event, EventEmitter, window } from 'vscode';
|
||||
import { debounce } from './decorators';
|
||||
import { fromGitUri } from './uri';
|
||||
import { Model } from './model';
|
||||
import { Repository } from './repository';
|
||||
|
||||
interface CacheRow {
|
||||
uri: Uri;
|
||||
@@ -30,7 +30,7 @@ export class GitContentProvider {
|
||||
private cache: Cache = Object.create(null);
|
||||
private disposables: Disposable[] = [];
|
||||
|
||||
constructor(private model: Model) {
|
||||
constructor(private model: Repository) {
|
||||
this.disposables.push(
|
||||
model.onDidChangeRepository(this.eventuallyFireChangeEvents, this),
|
||||
workspace.registerTextDocumentContentProvider('git', this)
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as nls from 'vscode-nls';
|
||||
const localize = nls.config(process.env.VSCODE_NLS_CONFIG)();
|
||||
import { ExtensionContext, workspace, window, Disposable, commands, Uri } from 'vscode';
|
||||
import { findGit, Git, IGit } from './git';
|
||||
import { Model } from './model';
|
||||
import { Repository } from './repository';
|
||||
import { ModelRegistry } from './modelRegistry';
|
||||
import { GitSCMProvider } from './scmProvider';
|
||||
import { CommandCenter } from './commands';
|
||||
@@ -46,8 +46,8 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
|
||||
}
|
||||
|
||||
const workspaceRoot = Uri.file(workspaceRootPath);
|
||||
const model = new Model(git, workspaceRoot);
|
||||
modelRegistry.register(workspaceRoot, model);
|
||||
const repository = new Repository(git, workspaceRoot);
|
||||
modelRegistry.register(workspaceRoot, repository);
|
||||
|
||||
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
|
||||
|
||||
@@ -56,17 +56,17 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
|
||||
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));
|
||||
|
||||
const commandCenter = new CommandCenter(git, modelRegistry, outputChannel, telemetryReporter);
|
||||
const statusBarCommands = new StatusBarCommands(model);
|
||||
const provider = new GitSCMProvider(model, statusBarCommands);
|
||||
const contentProvider = new GitContentProvider(model);
|
||||
const autoFetcher = new AutoFetcher(model);
|
||||
const statusBarCommands = new StatusBarCommands(repository);
|
||||
const provider = new GitSCMProvider(repository, statusBarCommands);
|
||||
const contentProvider = new GitContentProvider(repository);
|
||||
const autoFetcher = new AutoFetcher(repository);
|
||||
|
||||
disposables.push(
|
||||
commandCenter,
|
||||
provider,
|
||||
contentProvider,
|
||||
autoFetcher,
|
||||
model
|
||||
repository
|
||||
);
|
||||
|
||||
await checkGitVersion(info);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import { Uri, window, QuickPickItem } from 'vscode';
|
||||
import { Model } from './model';
|
||||
import { Repository } from './repository';
|
||||
import { memoize } from './decorators';
|
||||
import * as path from 'path';
|
||||
import * as nls from 'vscode-nls';
|
||||
@@ -16,18 +16,18 @@ const localize = nls.loadMessageBundle();
|
||||
class ModelPick implements QuickPickItem {
|
||||
@memoize get label(): string { return path.basename(this.repositoryRoot.fsPath); }
|
||||
@memoize get description(): string { return path.dirname(this.repositoryRoot.fsPath); }
|
||||
constructor(protected repositoryRoot: Uri, public readonly model: Model) { }
|
||||
constructor(protected repositoryRoot: Uri, public readonly model: Repository) { }
|
||||
}
|
||||
|
||||
export class ModelRegistry {
|
||||
|
||||
private models: Map<Uri, Model> = new Map<Uri, Model>();
|
||||
private models: Map<Uri, Repository> = new Map<Uri, Repository>();
|
||||
|
||||
register(uri: Uri, model): void {
|
||||
this.models.set(uri, model);
|
||||
}
|
||||
|
||||
async pickModel(): Promise<Model | undefined> {
|
||||
async pickModel(): Promise<Repository | undefined> {
|
||||
const picks = Array.from(this.models.entries(), ([uri, model]) => new ModelPick(uri, model));
|
||||
const placeHolder = localize('pick repo', "Choose a repository");
|
||||
const pick = await window.showQuickPick(picks, { placeHolder });
|
||||
@@ -35,7 +35,7 @@ export class ModelRegistry {
|
||||
return pick && pick.model;
|
||||
}
|
||||
|
||||
getModel(resource: Uri): Model | undefined {
|
||||
getModel(resource: Uri): Repository | undefined {
|
||||
const resourcePath = resource.fsPath;
|
||||
|
||||
for (let [repositoryRoot, model] of this.models) {
|
||||
@@ -50,7 +50,7 @@ export class ModelRegistry {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async resolve(resource: Uri): Promise<Model | undefined> {
|
||||
async resolve(resource: Uri): Promise<Repository | undefined> {
|
||||
const model = this.getModel(resource);
|
||||
|
||||
if (model) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import { Uri, Command, EventEmitter, Event, SourceControlResourceState, SourceControlResourceDecorations, Disposable, ProgressLocation, window, workspace, WorkspaceEdit } from 'vscode';
|
||||
import { Git, Repository, Ref, Branch, Remote, Commit, GitErrorCodes, Stash } from './git';
|
||||
import { Git, Repository as BaseRepository, Ref, Branch, Remote, Commit, GitErrorCodes, Stash } from './git';
|
||||
import { anyEvent, eventToPromise, filterEvent, EmptyDisposable, combinedDisposable, dispose, find } from './util';
|
||||
import { memoize, throttle, debounce } from './decorators';
|
||||
import * as path from 'path';
|
||||
@@ -295,7 +295,7 @@ export interface CommitOptions {
|
||||
signCommit?: boolean;
|
||||
}
|
||||
|
||||
export class Model implements Disposable {
|
||||
export class Repository implements Disposable {
|
||||
|
||||
private _onDidChangeRepository = new EventEmitter<Uri>();
|
||||
readonly onDidChangeRepository: Event<Uri> = this._onDidChangeRepository.event;
|
||||
@@ -349,7 +349,7 @@ export class Model implements Disposable {
|
||||
private _operations = new OperationsImpl();
|
||||
get operations(): Operations { return this._operations; }
|
||||
|
||||
private repository: Repository;
|
||||
private repository: BaseRepository;
|
||||
|
||||
private _state = State.Uninitialized;
|
||||
get state(): State { return this._state; }
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import { scm, Uri, Disposable, SourceControl, SourceControlResourceGroup, Event, workspace, commands } from 'vscode';
|
||||
import { Model, State, Status } from './model';
|
||||
import { Repository, State, Status } from './repository';
|
||||
import { StatusBarCommands } from './statusbar';
|
||||
import { mapEvent } from './util';
|
||||
import { toGitUri } from './uri';
|
||||
@@ -58,7 +58,7 @@ export class GitSCMProvider {
|
||||
private workingTreeGroup: SourceControlResourceGroup;
|
||||
|
||||
constructor(
|
||||
private model: Model,
|
||||
private model: Repository,
|
||||
private statusBarCommands: StatusBarCommands
|
||||
) {
|
||||
this._sourceControl = scm.createSourceControl('git', 'Git');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { Disposable, Command, EventEmitter, Event } from 'vscode';
|
||||
import { RefType, Branch } from './git';
|
||||
import { Model, Operation } from './model';
|
||||
import { Repository, Operation } from './repository';
|
||||
import { anyEvent, dispose } from './util';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
@@ -19,7 +19,7 @@ class CheckoutStatusBar {
|
||||
get onDidChange(): Event<void> { return this._onDidChange.event; }
|
||||
private disposables: Disposable[] = [];
|
||||
|
||||
constructor(private model: Model) {
|
||||
constructor(private model: Repository) {
|
||||
model.onDidChange(this._onDidChange.fire, this._onDidChange, this.disposables);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class SyncStatusBar {
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
|
||||
constructor(private model: Model) {
|
||||
constructor(private model: Repository) {
|
||||
model.onDidChange(this.onModelChange, this, this.disposables);
|
||||
model.onDidChangeOperations(this.onOperationsChange, this, this.disposables);
|
||||
this._onDidChange.fire();
|
||||
@@ -149,7 +149,7 @@ export class StatusBarCommands {
|
||||
private checkoutStatusBar: CheckoutStatusBar;
|
||||
private disposables: Disposable[] = [];
|
||||
|
||||
constructor(model: Model) {
|
||||
constructor(model: Repository) {
|
||||
this.syncStatusBar = new SyncStatusBar(model);
|
||||
this.checkoutStatusBar = new CheckoutStatusBar(model);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user