Revert "Merge from vscode merge-base (#22769)" (#22779)

This reverts commit 6bd0a17d3c.
This commit is contained in:
Karl Burtram
2023-04-18 21:44:05 -07:00
committed by GitHub
parent 6bd0a17d3c
commit 47a1745180
2389 changed files with 42588 additions and 92170 deletions

View File

@@ -354,7 +354,7 @@ function sanitizePath(path: string): string {
return path.replace(/^([a-z]):\\/i, (_, letter) => `${letter.toUpperCase()}:\\`);
}
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%ct%n%P%n%D%n%B';
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%ct%n%P%n%B';
/*export interface ICloneOptions { {{SQL CARBON EDIT}} moved to git.d.ts
readonly parentPath: string;
@@ -406,7 +406,7 @@ export class Git {
}
async clone(url: string, options: ICloneOptions, cancellationToken?: CancellationToken): Promise<string> {
const baseFolderName = decodeURI(url).replace(/[\/]+$/, '').replace(/^.*[\/\\]/, '').replace(/\.git$/, '') || 'repository';
let baseFolderName = decodeURI(url).replace(/[\/]+$/, '').replace(/^.*[\/\\]/, '').replace(/\.git$/, '') || 'repository';
let folderName = baseFolderName;
let folderPath = path.join(options.parentPath, folderName);
let count = 1;
@@ -447,7 +447,7 @@ export class Git {
};
try {
const command = ['clone', url.includes(' ') ? encodeURI(url) : url, folderPath, '--progress'];
let command = ['clone', url.includes(' ') ? encodeURI(url) : url, folderPath, '--progress'];
if (options.recursive) {
command.push('--recursive');
}
@@ -475,14 +475,13 @@ export class Git {
const repoPath = path.normalize(result.stdout.trimLeft().replace(/[\r\n]+$/, ''));
if (isWindows) {
// On Git 2.25+ if you call `rev-parse --show-toplevel` on a mapped drive, instead of getting the mapped
// drive path back, you get the UNC path for the mapped drive. So we will try to normalize it back to the
// mapped drive path, if possible
// On Git 2.25+ if you call `rev-parse --show-toplevel` on a mapped drive, instead of getting the mapped drive path back, you get the UNC path for the mapped drive.
// So we will try to normalize it back to the mapped drive path, if possible
const repoUri = Uri.file(repoPath);
const pathUri = Uri.file(repositoryPath);
if (repoUri.authority.length !== 0 && pathUri.authority.length === 0) {
// eslint-disable-next-line code-no-look-behind-regex
const match = /(?<=^\/?)([a-zA-Z])(?=:\/)/.exec(pathUri.path);
let match = /(?<=^\/?)([a-zA-Z])(?=:\/)/.exec(pathUri.path);
if (match !== null) {
const [, letter] = match;
@@ -505,13 +504,6 @@ export class Git {
return path.normalize(pathUri.fsPath);
}
// On Windows, there are cases in which the normalized path for a mapped folder contains a trailing `\`
// character (ex: \\server\folder\) due to the implementation of `path.normalize()`. This behaviour is
// by design as documented in https://github.com/nodejs/node/issues/1765.
if (repoUri.authority.length !== 0) {
return repoPath.replace(/\\$/, '');
}
}
return repoPath;
@@ -564,7 +556,9 @@ export class Git {
private async _exec(args: string[], options: SpawnOptions = {}): Promise<IExecutionResult<string>> {
const child = this.spawn(args, options);
options.onSpawn?.(child);
if (options.onSpawn) {
options.onSpawn(child);
}
if (options.input) {
child.stdin!.end(options.input, 'utf8');
@@ -666,7 +660,6 @@ export interface Commit {
authorName?: string;
authorEmail?: string;
commitDate?: Date;
refNames: string[];
}
export class GitStatusParser {
@@ -797,10 +790,10 @@ export function parseGitmodules(raw: string): Submodule[] {
return result;
}
const commitRegex = /([0-9a-f]{40})\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)(?:\n([^]*?))?(?:\x00)/gm;
const commitRegex = /([0-9a-f]{40})\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)(?:\n([^]*?))?(?:\x00)/gm;
export function parseGitCommits(data: string): Commit[] {
const commits: Commit[] = [];
let commits: Commit[] = [];
let ref;
let authorName;
@@ -808,7 +801,6 @@ export function parseGitCommits(data: string): Commit[] {
let authorDate;
let commitDate;
let parents;
let refNames;
let message;
let match;
@@ -818,7 +810,7 @@ export function parseGitCommits(data: string): Commit[] {
break;
}
[, ref, authorName, authorEmail, authorDate, commitDate, parents, refNames, message] = match;
[, ref, authorName, authorEmail, authorDate, commitDate, parents, message] = match;
if (message[message.length - 1] === '\n') {
message = message.substr(0, message.length - 1);
@@ -833,7 +825,6 @@ export function parseGitCommits(data: string): Commit[] {
authorName: ` ${authorName}`.substr(1),
authorEmail: ` ${authorEmail}`.substr(1),
commitDate: new Date(Number(commitDate) * 1000),
refNames: refNames.split(',').map(s => s.trim())
});
} while (true);
@@ -1406,37 +1397,20 @@ export class Repository {
}
async commit(message: string | undefined, opts: CommitOptions = Object.create(null)): Promise<void> {
const args = ['commit', '--quiet'];
const options: SpawnOptions = {};
if (message) {
options.input = message;
args.push('--allow-empty-message', '--file', '-');
}
if (opts.verbose) {
args.push('--verbose');
}
const args = ['commit', '--quiet', '--allow-empty-message'];
if (opts.all) {
args.push('--all');
}
if (opts.amend) {
if (opts.amend && message) {
args.push('--amend');
}
if (!opts.useEditor) {
if (!message) {
if (opts.amend) {
args.push('--no-edit');
} else {
options.input = '';
args.push('--file', '-');
}
}
args.push('--allow-empty-message');
if (opts.amend && !message) {
args.push('--amend', '--no-edit');
} else {
args.push('--file', '-');
}
if (opts.signoff) {
@@ -1461,7 +1435,7 @@ export class Repository {
}
try {
await this.exec(args, options);
await this.exec(args, !opts.amend || message ? { input: message || '' } : {});
} catch (commitErr) {
await this.handleCommitError(commitErr);
}
@@ -1475,7 +1449,7 @@ export class Repository {
const args = ['rebase', '--continue'];
try {
await this.exec(args, { env: { GIT_EDITOR: 'true' } });
await this.exec(args);
} catch (commitErr) {
await this.handleCommitError(commitErr);
}
@@ -1485,9 +1459,6 @@ export class Repository {
if (/not possible because you have unmerged files/.test(commitErr.stderr || '')) {
commitErr.gitErrorCode = GitErrorCodes.UnmergedChanges;
throw commitErr;
} else if (/Aborting commit due to empty commit message/.test(commitErr.stderr || '')) {
commitErr.gitErrorCode = GitErrorCodes.EmptyCommitMessage;
throw commitErr;
}
try {
@@ -1569,7 +1540,7 @@ export class Repository {
}
async deleteTag(name: string): Promise<void> {
const args = ['tag', '-d', name];
let args = ['tag', '-d', name];
await this.exec(args);
}
@@ -1793,12 +1764,12 @@ export class Repository {
} catch (err) {
if (/^error: failed to push some refs to\b/m.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.PushRejected;
} else if (/Permission.*denied/.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.PermissionDenied;
} else if (/Could not read from remote repository/.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.RemoteConnectionError;
} else if (/^fatal: The current branch .* has no upstream branch/.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.NoUpstreamBranch;
} else if (/Permission.*denied/.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.PermissionDenied;
}
throw err;