git: repository == scm provider

This commit is contained in:
Joao Moreno
2017-08-15 18:03:47 +02:00
parent 56d1dadf05
commit fe8ee2e7b8
8 changed files with 341 additions and 437 deletions

View File

@@ -19,25 +19,25 @@ class CheckoutStatusBar {
get onDidChange(): Event<void> { return this._onDidChange.event; }
private disposables: Disposable[] = [];
constructor(private model: Repository) {
model.onDidChange(this._onDidChange.fire, this._onDidChange, this.disposables);
constructor(private repository: Repository) {
repository.onDidChange(this._onDidChange.fire, this._onDidChange, this.disposables);
}
get command(): Command | undefined {
const HEAD = this.model.HEAD;
const HEAD = this.repository.HEAD;
if (!HEAD) {
return undefined;
}
const tag = this.model.refs.filter(iref => iref.type === RefType.Tag && iref.commit === HEAD.commit)[0];
const tag = this.repository.refs.filter(iref => iref.type === RefType.Tag && iref.commit === HEAD.commit)[0];
const tagName = tag && tag.name;
const head = HEAD.name || tagName || (HEAD.commit || '').substr(0, 8);
const title = '$(git-branch) '
+ head
+ (this.model.workingTreeGroup.resources.length > 0 ? '*' : '')
+ (this.model.indexGroup.resources.length > 0 ? '+' : '')
+ (this.model.mergeGroup.resources.length > 0 ? '!' : '');
+ (this.repository.workingTreeGroup.resourceStates.length > 0 ? '*' : '')
+ (this.repository.indexGroup.resourceStates.length > 0 ? '+' : '')
+ (this.repository.mergeGroup.resourceStates.length > 0 ? '!' : '');
return {
command: 'git.checkout',
@@ -76,24 +76,24 @@ class SyncStatusBar {
this._onDidChange.fire();
}
constructor(private model: Repository) {
model.onDidChange(this.onModelChange, this, this.disposables);
model.onDidChangeOperations(this.onOperationsChange, this, this.disposables);
constructor(private repository: Repository) {
repository.onDidChange(this.onModelChange, this, this.disposables);
repository.onDidChangeOperations(this.onOperationsChange, this, this.disposables);
this._onDidChange.fire();
}
private onOperationsChange(): void {
this.state = {
...this.state,
isSyncRunning: this.model.operations.isRunning(Operation.Sync)
isSyncRunning: this.repository.operations.isRunning(Operation.Sync)
};
}
private onModelChange(): void {
this.state = {
...this.state,
hasRemotes: this.model.remotes.length > 0,
HEAD: this.model.HEAD
hasRemotes: this.repository.remotes.length > 0,
HEAD: this.repository.HEAD
};
}
@@ -149,9 +149,9 @@ export class StatusBarCommands {
private checkoutStatusBar: CheckoutStatusBar;
private disposables: Disposable[] = [];
constructor(model: Repository) {
this.syncStatusBar = new SyncStatusBar(model);
this.checkoutStatusBar = new CheckoutStatusBar(model);
constructor(repository: Repository) {
this.syncStatusBar = new SyncStatusBar(repository);
this.checkoutStatusBar = new CheckoutStatusBar(repository);
}
get onDidChange(): Event<void> {