mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-28 08:04:00 +01:00
Adds onDidPublish to Git api
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Model } from '../model';
|
||||
import { Repository as BaseRepository, Resource } from '../repository';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, RemoteSourceProvider, CredentialsProvider, BranchQuery, PushErrorHandler } from './git';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, RemoteSourceProvider, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent } from './git';
|
||||
import { Event, SourceControlInputBox, Uri, SourceControl, Disposable, commands } from 'vscode';
|
||||
import { mapEvent } from '../util';
|
||||
import { toGitUri } from '../uri';
|
||||
@@ -237,6 +237,10 @@ export class ApiImpl implements API {
|
||||
return this._model.onDidChangeState;
|
||||
}
|
||||
|
||||
get onDidPublish(): Event<PublishEvent> {
|
||||
return this._model.onDidPublish;
|
||||
}
|
||||
|
||||
get onDidOpenRepository(): Event<Repository> {
|
||||
return mapEvent(this._model.onDidOpenRepository, r => new ApiRepository(r));
|
||||
}
|
||||
|
||||
Vendored
+6
@@ -231,9 +231,15 @@ export interface PushErrorHandler {
|
||||
|
||||
export type APIState = 'uninitialized' | 'initialized';
|
||||
|
||||
export interface PublishEvent {
|
||||
repository: Repository;
|
||||
branch?: string;
|
||||
}
|
||||
|
||||
export interface API {
|
||||
readonly state: APIState;
|
||||
readonly onDidChangeState: Event<APIState>;
|
||||
readonly onDidPublish: Event<PublishEvent>;
|
||||
readonly git: Git;
|
||||
readonly repositories: Repository[];
|
||||
readonly onDidOpenRepository: Event<Repository>;
|
||||
|
||||
@@ -2355,11 +2355,16 @@ export class CommandCenter {
|
||||
}
|
||||
|
||||
await provider.publishRepository!(new ApiRepository(repository));
|
||||
this.model.firePublishEvent(repository, branchName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (remotes.length === 1) {
|
||||
return await repository.pushTo(remotes[0].name, branchName, true);
|
||||
await repository.pushTo(remotes[0].name, branchName, true);
|
||||
this.model.firePublishEvent(repository, branchName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const addRemote = new AddRemoteItem(this);
|
||||
@@ -2376,9 +2381,13 @@ export class CommandCenter {
|
||||
|
||||
if (newRemote) {
|
||||
await repository.pushTo(newRemote, branchName, true);
|
||||
|
||||
this.model.firePublishEvent(repository, branchName);
|
||||
}
|
||||
} else {
|
||||
await repository.pushTo(choice.label, branchName, true);
|
||||
|
||||
this.model.firePublishEvent(repository, branchName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@ import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { fromGitUri } from './uri';
|
||||
import { APIState as State, RemoteSourceProvider, CredentialsProvider, PushErrorHandler } from './api/git';
|
||||
import { APIState as State, RemoteSourceProvider, CredentialsProvider, PushErrorHandler, PublishEvent } from './api/git';
|
||||
import { Askpass } from './askpass';
|
||||
import { IRemoteSourceProviderRegistry } from './remoteProvider';
|
||||
import { IPushErrorHandlerRegistry } from './pushError';
|
||||
import { ApiRepository } from './api/api1';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -69,6 +70,13 @@ export class Model implements IRemoteSourceProviderRegistry, IPushErrorHandlerRe
|
||||
private _onDidChangeState = new EventEmitter<State>();
|
||||
readonly onDidChangeState = this._onDidChangeState.event;
|
||||
|
||||
private _onDidPublish = new EventEmitter<PublishEvent>();
|
||||
readonly onDidPublish = this._onDidPublish.event;
|
||||
|
||||
firePublishEvent(repository: Repository, branch?: string) {
|
||||
this._onDidPublish.fire({ repository: new ApiRepository(repository), branch: branch });
|
||||
}
|
||||
|
||||
private _state: State = 'uninitialized';
|
||||
get state(): State { return this._state; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user