提交 689c38f4 编写于 作者: J Joao Moreno

💄

上级 4215f962
......@@ -39,8 +39,8 @@
}
},
{
"command": "git.loadRepo",
"title": "%command.loadRepo%",
"command": "git.openRepository",
"title": "%command.openRepository%",
"category": "Git",
"icon": {
"light": "resources/icons/light/git.svg",
......@@ -346,7 +346,7 @@
"when": "config.git.enabled"
},
{
"command": "git.loadRepo",
"command": "git.openRepository",
"when": "config.git.enabled"
},
{
......@@ -549,7 +549,7 @@
"when": "config.git.enabled && !scmProvider && gitOpenRepositoryCount == 0 && workspaceFolderCount != 0"
},
{
"command": "git.loadRepo",
"command": "git.openRepository",
"group": "navigation",
"when": "config.git.enabled && !scmProvider && gitOpenRepositoryCount == 0 && workspaceFolderCount != 0"
},
......
......@@ -3,7 +3,7 @@
"description": "Git SCM Integration",
"command.clone": "Clone",
"command.init": "Initialize Repository",
"command.loadRepo": "Load Repo",
"command.openRepository": "Open Repository",
"command.close": "Close Repository",
"command.refresh": "Refresh",
"command.openChange": "Open Changes",
......
......@@ -501,38 +501,28 @@ export class CommandCenter {
}
await this.git.init(path);
await this.model.tryOpenRepository(path);
await this.model.openRepository(path);
}
@command('git.loadRepo', { repository: false })
async loadRepo(path?: string): Promise<void> {
@command('git.openRepository', { repository: false })
async openRepository(path?: string): Promise<void> {
if (!path) {
path = await window.showInputBox({
prompt: localize('repopath', "Repository Path"),
ignoreFocusOut: true
const result = await window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
defaultUri: Uri.file(os.homedir()),
openLabel: localize('open repo', "Open Repository")
});
}
if (path) {
try {
if (this.model.getRepository(path)) {
await this.model.tryOpenRepository(path);
}
else {
window.showInformationMessage(localize('notfound', "Could not find a repository at this path"));
}
if (!result || result.length === 0) {
return;
}
catch (err) {
//If something went wrong, tryOpenRepository should have already given error
}
path = result[0].fsPath;
}
await this.model.openRepository(path);
}
@command('git.close', { repository: true })
......
......@@ -99,7 +99,7 @@ export class Model {
children
.filter(child => child !== '.git')
.forEach(child => this.tryOpenRepository(path.join(root, child)));
.forEach(child => this.openRepository(path.join(root, child)));
} catch (err) {
// noop
}
......@@ -118,7 +118,7 @@ export class Model {
@debounce(500)
private eventuallyScanPossibleGitRepositories(): void {
for (const path of this.possibleGitRepositoryPaths) {
this.tryOpenRepository(path);
this.openRepository(path);
}
this.possibleGitRepositoryPaths.clear();
......@@ -139,7 +139,7 @@ export class Model {
.filter(r => !activeRepositories.has(r!.repository))
.filter(r => !(workspace.workspaceFolders || []).some(f => isDescendant(f.uri.fsPath, r!.repository.root))) as OpenRepository[];
possibleRepositoryFolders.forEach(p => this.tryOpenRepository(p.uri.fsPath));
possibleRepositoryFolders.forEach(p => this.openRepository(p.uri.fsPath));
openRepositoriesToDispose.forEach(r => r.dispose());
}
......@@ -153,7 +153,7 @@ export class Model {
.filter(({ root }) => workspace.getConfiguration('git', root).get<boolean>('enabled') !== true)
.map(({ repository }) => repository);
possibleRepositoryFolders.forEach(p => this.tryOpenRepository(p.uri.fsPath));
possibleRepositoryFolders.forEach(p => this.openRepository(p.uri.fsPath));
openRepositoriesToDispose.forEach(r => r.dispose());
}
......@@ -178,12 +178,12 @@ export class Model {
return;
}
this.tryOpenRepository(path.dirname(uri.fsPath));
this.openRepository(path.dirname(uri.fsPath));
});
}
@sequentialize
async tryOpenRepository(path: string): Promise<void> {
async openRepository(path: string): Promise<void> {
if (this.getRepository(path)) {
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册