提交 3a12747e 编写于 作者: J Joao Moreno

fixes #21095

上级 6efcc518
......@@ -289,6 +289,11 @@ export class Git {
return new Repository(this, repository, env);
}
async init(repository: string): Promise<void> {
await this.exec(repository, ['init']);
return;
}
async clone(url: string, parentPath: string): Promise<string> {
const folderName = url.replace(/^.*\//, '').replace(/\.git$/, '') || 'repository';
const folderPath = path.join(parentPath, folderName);
......@@ -428,10 +433,6 @@ export class Repository {
return this.git.spawn(args, options);
}
init(): Promise<any> {
return this.run(['init']);
}
async config(scope: string, key: string, value: any, options: any): Promise<string> {
const args = ['config'];
......
......@@ -30,9 +30,9 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
const config = workspace.getConfiguration('git');
const enabled = config.get<boolean>('enabled') === true;
const rootPath = workspace.rootPath;
const workspaceRootPath = workspace.rootPath;
if (!rootPath || !enabled) {
if (!workspaceRootPath || !enabled) {
const commandCenter = new CommandCenter(undefined, outputChannel, telemetryReporter);
disposables.push(commandCenter);
return;
......@@ -42,7 +42,7 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
const info = await findGit(pathHint);
const git = new Git({ gitPath: info.path, version: info.version });
const askpass = new Askpass();
const model = new Model(git, rootPath, askpass);
const model = new Model(git, workspaceRootPath, askpass);
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
git.onOutput(str => outputChannel.append(str), null, disposables);
......
......@@ -355,7 +355,7 @@ export class Model implements Disposable {
constructor(
private _git: Git,
private rootPath: string,
private workspaceRootPath: string,
private askpass: Askpass
) {
const fsWatcher = workspace.createFileSystemWatcher('**');
......@@ -392,7 +392,7 @@ export class Model implements Disposable {
return;
}
await this.repository.init();
await this.git.init(this.workspaceRootPath);
await this.status();
}
......@@ -566,9 +566,9 @@ export class Model implements Disposable {
this.repositoryDisposable.dispose();
const disposables: Disposable[] = [];
const repositoryRoot = await this._git.getRepositoryRoot(this.rootPath);
const repositoryRoot = await this.git.getRepositoryRoot(this.workspaceRootPath);
const askpassEnv = await this.askpass.getEnv();
this.repository = this._git.open(repositoryRoot, askpassEnv);
this.repository = this.git.open(repositoryRoot, askpassEnv);
const dotGitPath = path.join(repositoryRoot, '.git');
const { event: onRawGitChange, disposable: watcher } = watch(dotGitPath);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册