Merge commit 'refs/pull/80335/head' of github.com:microsoft/vscode into pr/80335

This commit is contained in:
Joao Moreno
2019-10-09 12:44:34 +02:00
2 changed files with 25 additions and 9 deletions
+9 -2
View File
@@ -5,7 +5,7 @@
import { Uri, commands, Disposable, window, workspace, QuickPickItem, OutputChannel, Range, WorkspaceEdit, Position, LineChange, SourceControlResourceState, TextDocumentShowOptions, ViewColumn, ProgressLocation, TextEditor, MessageOptions, WorkspaceFolder } from 'vscode';
import { Git, CommitOptions, Stash, ForcePushMode } from './git';
import { Repository, Resource, ResourceGroupType } from './repository';
import { Repository, Resource, ResourceGroupType, getBranchName } from './repository';
import { Model } from './model';
import { toGitUri, fromGitUri } from './uri';
import { grep, isDescendant, pathEquals } from './util';
@@ -1371,9 +1371,16 @@ export class CommandCenter {
value = (await repository.getCommit(repository.HEAD.commit)).message;
}
let placeHolder;
const branchName = getBranchName(repository.HEAD, repository.refs);
if (branchName) {
placeHolder = localize('commitMessageWithHeadLabel2', "Message (commit on '{0}')", branchName);
} else {
placeHolder = localize('commit message', "Commit message");
}
return await window.showInputBox({
value,
placeHolder: localize('commit message', "Commit message"),
placeHolder,
prompt: localize('provide commit message', "Please provide a commit message"),
ignoreFocusOut: true
});
+16 -7
View File
@@ -1643,15 +1643,11 @@ export class Repository implements Disposable {
}
private updateInputBoxPlaceholder(): void {
const HEAD = this.HEAD;
if (HEAD) {
const tag = this.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 branchName = getBranchName(this.HEAD, this.refs);
if (branchName) {
// '{0}' will be replaced by the corresponding key-command later in the process, which is why it needs to stay.
this._sourceControl.inputBox.placeholder = localize('commitMessageWithHeadLabel', "Message ({0} to commit on '{1}')", "{0}", head);
this._sourceControl.inputBox.placeholder = localize('commitMessageWithHeadLabel', "Message ({0} to commit on '{1}')", "{0}", branchName);
} else {
this._sourceControl.inputBox.placeholder = localize('commitMessage', "Message ({0} to commit)");
}
@@ -1661,3 +1657,16 @@ export class Repository implements Disposable {
this.disposables = dispose(this.disposables);
}
}
export function getBranchName(HEAD: Repository['HEAD'], refs: Repository['refs']): string | undefined {
if (HEAD === undefined) {
return;
}
const tag = refs.filter(iref => iref.type === RefType.Tag && iref.commit === HEAD.commit)[0];
const tagName = tag && tag.name;
const branchName = HEAD.name || tagName || HEAD.commit;
if (branchName === undefined) {
return;
}
return branchName.substr(0, 8);
}