Merge from vscode fcf3346a8e9f5ee1e00674461d9e2c2292a14ee3 (#12295)

* Merge from vscode fcf3346a8e9f5ee1e00674461d9e2c2292a14ee3

* Fix test build break

* Update distro

* Fix build errors

* Update distro

* Update REH build file

* Update build task names for REL

* Fix product build yaml

* Fix product REH task name

* Fix type in task name

* Update linux build step

* Update windows build tasks

* Turn off server publish

* Disable REH

* Fix typo

* Bump distro

* Update vscode tests

* Bump distro

* Fix type in disto

* Bump distro

* Turn off docker build

* Remove docker step from release

Co-authored-by: ADS Merger <andresse@microsoft.com>
Co-authored-by: Karl Burtram <karlb@microsoft.com>
This commit is contained in:
Christopher Suh
2020-10-03 14:42:05 -04:00
committed by GitHub
parent 58d02b76db
commit 6ff1e3866b
687 changed files with 10507 additions and 9104 deletions

View File

@@ -130,6 +130,7 @@ export interface CommitOptions {
signoff?: boolean;
signCommit?: boolean;
empty?: boolean;
noVerify?: boolean;
}
export interface BranchQuery {

View File

@@ -6,7 +6,7 @@
import { lstat, Stats } from 'fs';
import * as os from 'os';
import * as path from 'path';
import { commands, Disposable, LineChange, MessageOptions, OutputChannel, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env } from 'vscode';
import { commands, Disposable, LineChange, MessageOptions, OutputChannel, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection } from 'vscode';
import TelemetryReporter from 'vscode-extension-telemetry';
import * as nls from 'vscode-nls';
import { Branch, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourceProvider } from './api/git';
@@ -1002,6 +1002,9 @@ export class CommandCenter {
}
await this._stageChanges(textEditor, [changes[index]]);
const firstStagedLine = changes[index].modifiedStartLineNumber - 1;
textEditor.selections = [new Selection(firstStagedLine, 0, firstStagedLine, 0)];
}
@command('git.stageSelectedRanges', { diff: true })
@@ -1049,6 +1052,9 @@ export class CommandCenter {
}
await this._revertChanges(textEditor, [...changes.slice(0, index), ...changes.slice(index + 1)]);
const firstStagedLine = changes[index].modifiedStartLineNumber - 1;
textEditor.selections = [new Selection(firstStagedLine, 0, firstStagedLine, 0)];
}
@command('git.revertSelectedRanges', { diff: true })
@@ -1070,7 +1076,9 @@ export class CommandCenter {
return;
}
const selectionsBeforeRevert = textEditor.selections;
await this._revertChanges(textEditor, selectedChanges);
textEditor.selections = selectionsBeforeRevert;
}
private async _revertChanges(textEditor: TextEditor, changes: LineChange[]): Promise<void> {
@@ -1083,7 +1091,6 @@ export class CommandCenter {
const originalUri = toGitUri(modifiedUri, '~');
const originalDocument = await workspace.openTextDocument(originalUri);
const selectionsBeforeRevert = textEditor.selections;
const visibleRangesBeforeRevert = textEditor.visibleRanges;
const result = applyLineChanges(originalDocument, modifiedDocument, changes);
@@ -1093,7 +1100,6 @@ export class CommandCenter {
await modifiedDocument.save();
textEditor.selections = selectionsBeforeRevert;
textEditor.revealRange(visibleRangesBeforeRevert[0]);
}
@@ -1435,6 +1441,26 @@ export class CommandCenter {
return false;
}
if (opts.noVerify) {
if (!config.get<boolean>('allowNoVerifyCommit')) {
await window.showErrorMessage(localize('no verify commit not allowed', "Commits without verification are not allowed, please enable them with the 'git.allowNoVerifyCommit' setting."));
return false;
}
if (config.get<boolean>('confirmNoVerifyCommit')) {
const message = localize('confirm no verify commit', "You are about to commit your changes without verification, this skips pre-commit hooks and can be undesirable.\n\nAre you sure to continue?");
const yes = localize('ok', "OK");
const neverAgain = localize('never ask again', "OK, Don't Ask Again");
const pick = await window.showWarningMessage(message, { modal: true }, yes, neverAgain);
if (pick === neverAgain) {
config.update('confirmNoVerifyCommit', false, true);
} else if (pick !== yes) {
return false;
}
}
}
const message = await getCommitMessage();
if (!message) {
@@ -1539,8 +1565,7 @@ export class CommandCenter {
await this.commitWithAnyInput(repository, { all: true, amend: true });
}
@command('git.commitEmpty', { repository: true })
async commitEmpty(repository: Repository): Promise<void> {
private async _commitEmpty(repository: Repository, noVerify?: boolean): Promise<void> {
const root = Uri.file(repository.root);
const config = workspace.getConfiguration('git', root);
const shouldPrompt = config.get<boolean>('confirmEmptyCommits') === true;
@@ -1558,7 +1583,52 @@ export class CommandCenter {
}
}
await this.commitWithAnyInput(repository, { empty: true });
await this.commitWithAnyInput(repository, { empty: true, noVerify });
}
@command('git.commitEmpty', { repository: true })
async commitEmpty(repository: Repository): Promise<void> {
await this._commitEmpty(repository);
}
@command('git.commitNoVerify', { repository: true })
async commitNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { noVerify: true });
}
@command('git.commitStagedNoVerify', { repository: true })
async commitStagedNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: false, noVerify: true });
}
@command('git.commitStagedSignedNoVerify', { repository: true })
async commitStagedSignedNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: false, signoff: true, noVerify: true });
}
@command('git.commitStagedAmendNoVerify', { repository: true })
async commitStagedAmendNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: false, amend: true, noVerify: true });
}
@command('git.commitAllNoVerify', { repository: true })
async commitAllNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: true, noVerify: true });
}
@command('git.commitAllSignedNoVerify', { repository: true })
async commitAllSignedNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: true, signoff: true, noVerify: true });
}
@command('git.commitAllAmendNoVerify', { repository: true })
async commitAllAmendNoVerify(repository: Repository): Promise<void> {
await this.commitWithAnyInput(repository, { all: true, amend: true, noVerify: true });
}
@command('git.commitEmptyNoVerify', { repository: true })
async commitEmptyNoVerify(repository: Repository): Promise<void> {
await this._commitEmpty(repository, true);
}
@command('git.restoreCommitTemplate', { repository: true })

View File

@@ -21,7 +21,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
constructor(private model: Model) {
this.onDidChangeDecorations = fireEvent(anyEvent<any>(
filterEvent(workspace.onDidSaveTextDocument, e => e.fileName.endsWith('.gitignore')),
filterEvent(workspace.onDidSaveTextDocument, e => /\.gitignore$|\.git\/info\/exclude$/.test(e.uri.path)),
model.onDidOpenRepository,
model.onDidCloseRepository
));

View File

@@ -139,18 +139,28 @@ function findGitWin32(onLookup: (path: string) => void): Promise<IGit> {
.then(undefined, () => findGitWin32InPath(onLookup));
}
export function findGit(hint: string | undefined, onLookup: (path: string) => void): Promise<IGit> {
const first = hint ? findSpecificGit(hint, onLookup) : Promise.reject<IGit>(null);
export async function findGit(hint: string | string[] | undefined, onLookup: (path: string) => void): Promise<IGit> {
const hints = Array.isArray(hint) ? hint : hint ? [hint] : [];
return first
.then(undefined, () => {
switch (process.platform) {
case 'darwin': return findGitDarwin(onLookup);
case 'win32': return findGitWin32(onLookup);
default: return findSpecificGit('git', onLookup);
}
})
.then(null, () => Promise.reject(new Error('Git installation not found.')));
for (const hint of hints) {
try {
return await findSpecificGit(hint, onLookup);
} catch {
// noop
}
}
try {
switch (process.platform) {
case 'darwin': return await findGitDarwin(onLookup);
case 'win32': return await findGitWin32(onLookup);
default: return await findSpecificGit('git', onLookup);
}
} catch {
// noop
}
throw new Error('Git installation not found.');
}
export interface IExecutionResult<T extends string | Buffer> {
@@ -1322,10 +1332,15 @@ export class Repository {
if (opts.signCommit) {
args.push('-S');
}
if (opts.empty) {
args.push('--allow-empty');
}
if (opts.noVerify) {
args.push('--no-verify');
}
try {
await this.run(args, { input: message || '' });
} catch (commitErr) {

View File

@@ -33,7 +33,7 @@ export async function deactivate(): Promise<any> {
}
async function createModel(context: ExtensionContext, outputChannel: OutputChannel, telemetryReporter: TelemetryReporter, disposables: Disposable[]): Promise<Model> {
const pathHint = workspace.getConfiguration('git').get<string>('path');
const pathHint = workspace.getConfiguration('git').get<string | string[]>('path');
const info = await findGit(pathHint, path => outputChannel.appendLine(localize('looking', "Looking for git in: {0}", path)));
const askpass = await Askpass.create(outputChannel, context.storagePath);

View File

@@ -6,7 +6,7 @@
import { workspace, WorkspaceFoldersChangeEvent, Uri, window, Event, EventEmitter, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup, TextEditor, Memento, OutputChannel, commands } from 'vscode';
import { Repository, RepositoryState } from './repository';
import { memoize, sequentialize, debounce } from './decorators';
import { dispose, anyEvent, filterEvent, isDescendant, firstIndex, pathEquals, toDisposable, eventToPromise } from './util';
import { dispose, anyEvent, filterEvent, isDescendant, pathEquals, toDisposable, eventToPromise } from './util';
import { Git } from './git';
import * as path from 'path';
import * as fs from 'fs';
@@ -372,7 +372,7 @@ export class Model implements IRemoteSourceProviderRegistry, IPushErrorHandlerRe
const picks = this.openRepositories.map((e, index) => new RepositoryPick(e.repository, index));
const active = window.activeTextEditor;
const repository = active && this.getRepository(active.document.fileName);
const index = firstIndex(picks, pick => pick.repository === repository);
const index = picks.findIndex(pick => pick.repository === repository);
// Move repository pick containing the active text editor to appear first
if (index > -1) {

View File

@@ -182,16 +182,6 @@ export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
};
}
export function firstIndex<T>(array: T[], fn: (t: T) => boolean): number {
for (let i = 0; i < array.length; i++) {
if (fn(array[i])) {
return i;
}
}
return -1;
}
export function find<T>(array: T[], fn: (t: T) => boolean): T | undefined {
let result: T | undefined = undefined;