提交 4b90d9ba 编写于 作者: A al

Add branch name to commit input box

上级 b30aba88
......@@ -1370,9 +1370,10 @@ export class CommandCenter {
value = (await repository.getCommit(repository.HEAD.commit)).message;
}
const branchName = repository.getBranchName();
return await window.showInputBox({
value,
placeHolder: localize('commit message', "Commit message"),
placeHolder: branchName ? localize('commitMessageWithHeadLabel2', "Message (commit on '{0}')", branchName) : localize('commit message', "Commit message"),
prompt: localize('provide commit message', "Please provide a commit message"),
ignoreFocusOut: true
});
......
......@@ -1653,20 +1653,26 @@ 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 = this.getBranchName();
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)");
}
}
getBranchName(): string | undefined {
const HEAD = this.HEAD;
if (HEAD === undefined) {
return;
}
const tag = this.refs.filter(iref => iref.type === RefType.Tag && iref.commit === HEAD.commit)[0];
const tagName = tag && tag.name;
return HEAD.name || tagName || (HEAD.commit || '').substr(0, 8);
}
dispose(): void {
this.disposables = dispose(this.disposables);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册