Merge remote-tracking branch 'origin/master' into joao/git-fs-provider

This commit is contained in:
Joao Moreno
2019-11-14 11:10:41 +01:00
502 changed files with 8792 additions and 6839 deletions

View File

@@ -5,8 +5,6 @@
import * as jschardet from 'jschardet';
jschardet.Constants.MINIMUM_THRESHOLD = 0.2;
function detectEncodingByBOM(buffer: Buffer): string | null {
if (!buffer || buffer.length < 2) {
return null;

View File

@@ -1813,10 +1813,18 @@ export class Repository {
}
cleanupCommitEditMessage(message: string): string {
//TODO: Support core.commentChar
return message.replace(/^\s*#.*$\n?/gm, '').trim();
}
// 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();
}
async getMergeMessage(): Promise<string | undefined> {
const mergeMsgPath = path.join(this.repositoryRoot, '.git', 'MERGE_MSG');

View File

@@ -844,7 +844,15 @@ export class Repository implements Disposable {
return mergeMessage;
}
return await this.repository.getCommitTemplate();
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;
}
getConfigs(): Promise<{ key: string; value: string; }[]> {
@@ -1278,7 +1286,7 @@ export class Repository implements Disposable {
return await this.run(Operation.GetCommitTemplate, async () => this.repository.getCommitTemplate());
}
async cleanUpCommitEditMessage(editMessage: string): Promise<string> {
cleanUpCommitEditMessage(editMessage: string): string {
return this.repository.cleanupCommitEditMessage(editMessage);
}

View File

@@ -1,11 +0,0 @@
declare module 'jschardet' {
export interface IDetectedMap {
encoding: string,
confidence: number
}
export function detect(buffer: Buffer): IDetectedMap;
export const Constants: {
MINIMUM_THRESHOLD: number,
}
}