提交 07885099 编写于 作者: J Joao Moreno

Merge branch '31055-Sync-Rebase' of https://github.com/excerebrose/vscode into...

Merge branch '31055-Sync-Rebase' of https://github.com/excerebrose/vscode into excerebrose-31055-Sync-Rebase
......@@ -264,6 +264,11 @@
"title": "%command.sync%",
"category": "Git"
},
{
"command": "git.syncRebase",
"title": "%command.syncRebase%",
"category": "Git"
},
{
"command": "git.publish",
"title": "%command.publish%",
......@@ -449,6 +454,10 @@
"command": "git.sync",
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
},
{
"command": "git.syncRebase",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.publish",
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
......@@ -495,6 +504,11 @@
"group": "1_sync",
"when": "config.git.enabled && scmProvider == git"
},
{
"command": "git.syncRebase",
"group": "1_sync",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.pull",
"group": "1_sync",
......
......@@ -37,6 +37,7 @@
"command.pushTo": "Push to...",
"command.pushWithTags": "Push With Tags",
"command.sync": "Sync",
"command.syncRebase": "Sync (Rebase)",
"command.publish": "Publish Branch",
"command.showOutput": "Show Git Output",
"command.ignore": "Add File to .gitignore",
......
......@@ -1280,6 +1280,32 @@ export class CommandCenter {
}));
}
@command('git.syncRebase', { repository: true })
async syncRebase(repository: Repository): Promise<void> {
const HEAD = repository.HEAD;
if (!HEAD || !HEAD.upstream) {
return;
}
const config = workspace.getConfiguration('git');
const shouldPrompt = config.get<boolean>('confirmSync') === true;
if (shouldPrompt) {
const message = localize('sync is unpredictable', "This action will push and pull commits to and from '{0}'.", HEAD.upstream);
const yes = localize('ok', "OK");
const neverAgain = localize('never again', "OK, Never Show Again");
const pick = await window.showWarningMessage(message, { modal: true }, yes, neverAgain);
if (pick === neverAgain) {
await config.update('confirmSync', false, true);
} else if (pick !== yes) {
return;
}
}
await repository.syncRebase();
}
@command('git.publish', { repository: true })
async publish(repository: Repository): Promise<void> {
const remotes = repository.remotes;
......
......@@ -664,6 +664,19 @@ export class Repository implements Disposable {
});
}
@throttle
async syncRebase(): Promise<void> {
await this.run(Operation.Sync, async () => {
await this.repository.pull(true);
const shouldPush = this.HEAD && typeof this.HEAD.ahead === 'number' ? this.HEAD.ahead > 0 : true;
if (shouldPush) {
await this.repository.push();
}
});
}
async show(ref: string, filePath: string): Promise<string> {
return await this.run(Operation.Show, async () => {
const relativePath = path.relative(this.repository.root, filePath).replace(/\\/g, '/');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册