Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/oss/master' into distro
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Oct 15, 2019
2 parents 9d47c99 + 43e85c2 commit 2cbf514
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 53 deletions.
41 changes: 21 additions & 20 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1361,37 +1361,38 @@ export class CommandCenter {
private async commitWithAnyInput(repository: Repository, opts?: CommitOptions): Promise<void> {
const message = repository.inputBox.value;
const getCommitMessage = async () => {
if (message) {
return message;
}
let _message: string | undefined = message;
if (!_message) {
let value: string | undefined = undefined;

let value: string | undefined = undefined;
if (opts && opts.amend && repository.HEAD && repository.HEAD.commit) {
value = (await repository.getCommit(repository.HEAD.commit)).message;
}

if (opts && opts.amend && repository.HEAD && repository.HEAD.commit) {
value = (await repository.getCommit(repository.HEAD.commit)).message;
}
const branchName = repository.headShortName;
let placeHolder: string;

const branchName = repository.headShortName;
let placeHolder: string;
if (branchName) {
placeHolder = localize('commitMessageWithHeadLabel2', "Message (commit on '{0}')", branchName);
} else {
placeHolder = localize('commit message', "Commit message");
}

if (branchName) {
placeHolder = localize('commitMessageWithHeadLabel2', "Message (commit on '{0}')", branchName);
} else {
placeHolder = localize('commit message', "Commit message");
_message = await window.showInputBox({
value,
placeHolder,
prompt: localize('provide commit message', "Please provide a commit message"),
ignoreFocusOut: true
});
}

return await window.showInputBox({
value,
placeHolder,
prompt: localize('provide commit message', "Please provide a commit message"),
ignoreFocusOut: true
});
return _message ? repository.cleanUpCommitEditMessage(_message) : _message;
};

const didCommit = await this.smartCommit(repository, getCommitMessage, opts);

if (message && didCommit) {
repository.inputBox.value = await repository.getCommitTemplate();
repository.inputBox.value = await repository.getInputTemplate();
}
}

Expand Down
19 changes: 18 additions & 1 deletion extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,23 @@ export class Repository {
}
}

cleanupCommitEditMessage(message: string): string {
//TODO: Support core.commentChar
return message.replace(/^\s*#.*$\n?/gm, '').trim();
}


async getMergeMessage(): Promise<string | undefined> {
const mergeMsgPath = path.join(this.repositoryRoot, '.git', 'MERGE_MSG');

try {
const raw = await readfile(mergeMsgPath, 'utf8');
return raw.trim();
} catch {
return undefined;
}
}

async getCommitTemplate(): Promise<string> {
try {
const result = await this.run(['config', '--get', 'commit.template']);
Expand All @@ -1766,7 +1783,7 @@ export class Repository {
}

const raw = await readfile(templatePath, 'utf8');
return raw.replace(/^\s*#.*$\n?/gm, '');
return raw.trim();

} catch (err) {
return '';
Expand Down
20 changes: 13 additions & 7 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,6 @@ export class Repository implements Disposable {
const onDidChangeCountBadge = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.countBadge', root));
onDidChangeCountBadge(this.setCountBadge, this, this.disposables);
this.setCountBadge();

this.updateCommitTemplate();
}

validateInput(text: string, position: number): SourceControlInputBoxValidation | undefined {
Expand Down Expand Up @@ -827,12 +825,14 @@ export class Repository implements Disposable {
return toGitUri(uri, '', { replaceFileExtension: true });
}

private async updateCommitTemplate(): Promise<void> {
try {
this._sourceControl.commitTemplate = await this.repository.getCommitTemplate();
} catch (e) {
// noop
async getInputTemplate(): Promise<string> {
const mergeMessage = await this.repository.getMergeMessage();

if (mergeMessage) {
return mergeMessage;
}

return await this.repository.getCommitTemplate();
}

getConfigs(): Promise<{ key: string; value: string; }[]> {
Expand Down Expand Up @@ -1257,6 +1257,10 @@ export class Repository implements Disposable {
return await this.run(Operation.GetCommitTemplate, async () => this.repository.getCommitTemplate());
}

async cleanUpCommitEditMessage(editMessage: string): Promise<string> {
return this.repository.cleanupCommitEditMessage(editMessage);
}

async ignore(files: Uri[]): Promise<void> {
return await this.run(Operation.Ignore, async () => {
const ignoreFile = `${this.repository.root}${path.sep}.gitignore`;
Expand Down Expand Up @@ -1528,6 +1532,8 @@ export class Repository implements Disposable {
this.setCountBadge();

this._onDidChangeStatus.fire();

this._sourceControl.commitTemplate = await this.getInputTemplate();
}

private setCountBadge(): void {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.40.0",
"distro": "82c617d0e12653f83c0757f3dea3f8c11911908d",
"distro": "9d47c99bab712c0ffd0e0dfccaa1eab1994ecfdf",
"author": {
"name": "Microsoft Corporation"
},
Expand Down Expand Up @@ -53,7 +53,7 @@
"vscode-sqlite3": "4.0.8",
"vscode-textmate": "^4.2.2",
"vsda": "https://github.com/microsoft/vsda.git#45edd3db96a5e308a5cfc817d1ee42f6d96e1659",
"xterm": "4.2.0-beta4",
"xterm": "4.2.0-beta8",
"xterm-addon-search": "0.3.0-beta5",
"xterm-addon-web-links": "0.2.0",
"yauzl": "^2.9.2",
Expand Down
2 changes: 1 addition & 1 deletion remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"vscode-ripgrep": "^1.5.7",
"vscode-textmate": "^4.2.2",
"vsda": "https://github.com/microsoft/vsda.git#45edd3db96a5e308a5cfc817d1ee42f6d96e1659",
"xterm": "4.2.0-beta4",
"xterm": "4.2.0-beta8",
"xterm-addon-search": "0.3.0-beta5",
"xterm-addon-web-links": "0.2.0",
"yauzl": "^2.9.2",
Expand Down
2 changes: 1 addition & 1 deletion remote/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"onigasm-umd": "^2.2.2",
"semver-umd": "^5.5.3",
"vscode-textmate": "^4.2.2",
"xterm": "4.2.0-beta4",
"xterm": "4.2.0-beta8",
"xterm-addon-search": "0.3.0-beta5",
"xterm-addon-web-links": "0.2.0"
}
Expand Down
8 changes: 4 additions & 4 deletions remote/web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ xterm-addon-web-links@0.2.0:
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.0.tgz#b408a0be46211d8d4a0bb5e701d8f3c2bd07d473"
integrity sha512-dq81c4Pzli2PgKVBgY2REte9sCVibR3df8AP3SEvCTM9uYFnUFxtxzMTplPnc7+rXabVhFdbU6x+rstIk8HNQg==

xterm@4.2.0-beta4:
version "4.2.0-beta4"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.2.0-beta4.tgz#596577f94a1da372119d192363ea2b19d1f8b50c"
integrity sha512-BmkpxCpqdOJoNdIcddkRT8S65sGjgBbWI0uIJNSnzZvj81OKcraMSTmF/ODw0TF/MDLc33Fx9cpDx/D6lQgl8Q==
xterm@4.2.0-beta8:
version "4.2.0-beta8"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.2.0-beta8.tgz#f375cfef7d58240c56ba23c8ca1c36399ab7ccb1"
integrity sha512-oka51TIzcmxwpJaoV180bkynYiMW2H0rN7J9gehofEFFX7nHRxIh/tm9EzUEA8I9ELYB91a9TQc7V1PQSN+Mlw==
8 changes: 4 additions & 4 deletions remote/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ xterm-addon-web-links@0.2.0:
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.0.tgz#b408a0be46211d8d4a0bb5e701d8f3c2bd07d473"
integrity sha512-dq81c4Pzli2PgKVBgY2REte9sCVibR3df8AP3SEvCTM9uYFnUFxtxzMTplPnc7+rXabVhFdbU6x+rstIk8HNQg==

xterm@4.2.0-beta4:
version "4.2.0-beta4"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.2.0-beta4.tgz#596577f94a1da372119d192363ea2b19d1f8b50c"
integrity sha512-BmkpxCpqdOJoNdIcddkRT8S65sGjgBbWI0uIJNSnzZvj81OKcraMSTmF/ODw0TF/MDLc33Fx9cpDx/D6lQgl8Q==
xterm@4.2.0-beta8:
version "4.2.0-beta8"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.2.0-beta8.tgz#f375cfef7d58240c56ba23c8ca1c36399ab7ccb1"
integrity sha512-oka51TIzcmxwpJaoV180bkynYiMW2H0rN7J9gehofEFFX7nHRxIh/tm9EzUEA8I9ELYB91a9TQc7V1PQSN+Mlw==

yauzl@^2.9.2:
version "2.10.0"
Expand Down
2 changes: 1 addition & 1 deletion src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6333,7 +6333,7 @@ declare module 'vscode' {
export function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;

/**
* Retrieve the list of all available commands. Commands starting an underscore are
* Retrieve the list of all available commands. Commands starting with an underscore are
* treated as internal commands.
*
* @param filterInternal Set `true` to not see internal commands (starting with an underscore)
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/mainThreadSCM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class MainThreadSCMProvider implements ISCMProvider {
get rootUri(): URI | undefined { return this._rootUri; }
get contextValue(): string { return this._contextValue; }

get commitTemplate(): string | undefined { return this.features.commitTemplate; }
get commitTemplate(): string { return this.features.commitTemplate || ''; }
get acceptInputCommand(): Command | undefined { return this.features.acceptInputCommand; }
get statusBarCommands(): Command[] | undefined { return this.features.statusBarCommands; }
get count(): number | undefined { return this.features.count; }
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHostSCM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ class ExtHostSourceControl implements vscode.SourceControl {
}

set commitTemplate(commitTemplate: string | undefined) {
if (commitTemplate === this._commitTemplate) {
return;
}

this._commitTemplate = commitTemplate;
this._proxy.$updateSourceControl(this.handle, { commitTemplate });
}
Expand Down
18 changes: 13 additions & 5 deletions src/vs/workbench/contrib/scm/browser/repositoryPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ export class RepositoryPanel extends ViewletPanel {
private menus: SCMMenus;
private toggleViewModelModeAction: ToggleViewModeAction | undefined;
protected contextKeyService: IContextKeyService;
private commitTemplate = '';

constructor(
readonly repository: ISCMRepository,
Expand Down Expand Up @@ -698,10 +699,10 @@ export class RepositoryPanel extends ViewletPanel {
this._register(this.inputBox.onDidHeightChange(() => this.layoutBody()));

if (this.repository.provider.onDidChangeCommitTemplate) {
this._register(this.repository.provider.onDidChangeCommitTemplate(this.updateInputBox, this));
this._register(this.repository.provider.onDidChangeCommitTemplate(this.onDidChangeCommitTemplate, this));
}

this.updateInputBox();
this.onDidChangeCommitTemplate();

// Input box visibility
this._register(this.repository.input.onDidChangeVisibility(this.updateInputBoxVisibility, this));
Expand Down Expand Up @@ -922,12 +923,19 @@ export class RepositoryPanel extends ViewletPanel {
.filter(r => !!r && !isSCMResourceGroup(r))! as any;
}

private updateInputBox(): void {
if (typeof this.repository.provider.commitTemplate === 'undefined' || !this.repository.input.visible || this.inputBox.value) {
private onDidChangeCommitTemplate(): void {
if (typeof this.repository.provider.commitTemplate === 'undefined' || !this.repository.input.visible) {
return;
}

this.inputBox.value = this.repository.provider.commitTemplate;
const oldCommitTemplate = this.commitTemplate;
this.commitTemplate = this.repository.provider.commitTemplate;

if (this.inputBox.value && this.inputBox.value !== oldCommitTemplate) {
return;
}

this.inputBox.value = this.commitTemplate;
}

private updateInputBoxVisibility(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/scm/common/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export interface ISCMProvider extends IDisposable {

readonly rootUri?: URI;
readonly count?: number;
readonly commitTemplate?: string;
readonly onDidChangeCommitTemplate?: Event<string>;
readonly commitTemplate: string;
readonly onDidChangeCommitTemplate: Event<string>;
readonly onDidChangeStatusBarCommands?: Event<Command[]>;
readonly acceptInputCommand?: Command;
readonly statusBarCommands?: Command[];
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9280,10 +9280,10 @@ xterm-addon-web-links@0.2.0:
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.0.tgz#b408a0be46211d8d4a0bb5e701d8f3c2bd07d473"
integrity sha512-dq81c4Pzli2PgKVBgY2REte9sCVibR3df8AP3SEvCTM9uYFnUFxtxzMTplPnc7+rXabVhFdbU6x+rstIk8HNQg==

xterm@4.2.0-beta4:
version "4.2.0-beta4"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.2.0-beta4.tgz#596577f94a1da372119d192363ea2b19d1f8b50c"
integrity sha512-BmkpxCpqdOJoNdIcddkRT8S65sGjgBbWI0uIJNSnzZvj81OKcraMSTmF/ODw0TF/MDLc33Fx9cpDx/D6lQgl8Q==
xterm@4.2.0-beta8:
version "4.2.0-beta8"
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.2.0-beta8.tgz#f375cfef7d58240c56ba23c8ca1c36399ab7ccb1"
integrity sha512-oka51TIzcmxwpJaoV180bkynYiMW2H0rN7J9gehofEFFX7nHRxIh/tm9EzUEA8I9ELYB91a9TQc7V1PQSN+Mlw==

y18n@^3.2.1:
version "3.2.1"
Expand Down

0 comments on commit 2cbf514

Please sign in to comment.