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

git input box shouldn't handle comments

related to #84201
上级 3b0571d8
......@@ -1608,12 +1608,6 @@
"default": "mixed",
"description": "%config.untrackedChanges%",
"scope": "resource"
},
"git.restoreCommitTemplateComments": {
"type": "boolean",
"scope": "resource",
"default": true,
"description": "%config.restoreCommitTemplateComments%"
}
}
},
......
......@@ -139,7 +139,6 @@
"config.untrackedChanges.mixed": "All changes, tracked and untracked, appear together and behave equally.",
"config.untrackedChanges.separate": "Untracked changes appear separately in the Source Control view. They are also excluded from several actions.",
"config.untrackedChanges.hidden": "Untracked changes are hidden and excluded from several actions.",
"config.restoreCommitTemplateComments": "Controls whether to restore commit template comments in the commit input box.",
"colors.added": "Color for added resources.",
"colors.modified": "Color for modified resources.",
"colors.deleted": "Color for deleted resources.",
......
......@@ -1406,6 +1406,7 @@ export class CommandCenter {
const message = repository.inputBox.value;
const getCommitMessage = async () => {
let _message: string | undefined = message;
if (!_message) {
let value: string | undefined = undefined;
......@@ -1430,7 +1431,7 @@ export class CommandCenter {
});
}
return _message ? repository.cleanUpCommitEditMessage(_message) : _message;
return _message;
};
const didCommit = await this.smartCommit(repository, getCommitMessage, opts);
......
......@@ -1810,18 +1810,9 @@ export class Repository {
}
}
cleanupCommitEditMessage(message: string): string {
// If the message is a single line starting with whitespace followed by `#`, just allow it.
if (/^\s*#[^\n]*$/.test(message)) {
return message;
}
// Else, remove all lines starting with whitespace followed by `#`.
// TODO: Support core.commentChar
return message.replace(/^(\s*#)(.*)$(\n?)/gm, (_, prefix, content, suffix) => {
// https://github.com/microsoft/vscode/issues/84201#issuecomment-552834814
return /^\d/.test(content) ? `${prefix}${content}${suffix}` : '';
}).trim();
// TODO: Support core.commentChar
stripCommitMessageComments(message: string): string {
return message.replace(/^\s*#.*$\n?/gm, '').trim();
}
async getMergeMessage(): Promise<string | undefined> {
......@@ -1829,7 +1820,7 @@ export class Repository {
try {
const raw = await fs.readFile(mergeMsgPath, 'utf8');
return raw.trim();
return this.stripCommitMessageComments(raw);
} catch {
return undefined;
}
......@@ -1853,8 +1844,7 @@ export class Repository {
}
const raw = await fs.readFile(templatePath, 'utf8');
return raw.trim();
return this.stripCommitMessageComments(raw);
} catch (err) {
return '';
}
......
......@@ -844,15 +844,7 @@ export class Repository implements Disposable {
return mergeMessage;
}
let template = await this.repository.getCommitTemplate();
const config = workspace.getConfiguration('git', Uri.file(this.root));
if (!config.get<boolean>('restoreCommitTemplateComments')) {
template = this.cleanUpCommitEditMessage(template);
}
return template;
return await this.repository.getCommitTemplate();
}
getConfigs(): Promise<{ key: string; value: string; }[]> {
......@@ -1286,10 +1278,6 @@ export class Repository implements Disposable {
return await this.run(Operation.GetCommitTemplate, async () => this.repository.getCommitTemplate());
}
cleanUpCommitEditMessage(editMessage: string): 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`;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册