Skip to content

Commit

Permalink
Merge branch 'microsoft:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
d0a1c3f7 authored Jul 11, 2024
2 parents 3cf6736 + c37f4a4 commit 8129f61
Show file tree
Hide file tree
Showing 46 changed files with 704 additions and 288 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"version": "1.0.8",
"resolved": "ghcr.io/devcontainers/features/desktop-lite@sha256:e7dc4d37ab9e3d6e7ebb221bac741f5bfe07dae47025399d038b17af2ed8ddb7",
"integrity": "sha256:e7dc4d37ab9e3d6e7ebb221bac741f5bfe07dae47025399d038b17af2ed8ddb7"
},
"ghcr.io/devcontainers/features/rust:1": {
"version": "1.1.3",
"resolved": "ghcr.io/devcontainers/features/rust@sha256:aba6f47303b197976902bf544c786b5efecc03c238ff593583e5e74dfa9c7ccb",
"integrity": "sha256:aba6f47303b197976902bf544c786b5efecc03c238ff593583e5e74dfa9c7ccb"
}
}
}
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {}
"ghcr.io/devcontainers/features/desktop-lite:1": {},
"ghcr.io/devcontainers/features/rust:1": {}
},
"containerEnv": {
"DISPLAY": "" // Allow the Dev Containers extension to set DISPLAY, post-create.sh will add it back in ~/.bashrc and ~/.zshrc if not set.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
with:
appInsightsKey: ${{secrets.TRIAGE_ACTIONS_APP_INSIGHTS}}
token: ${{secrets.VSCODE_ISSUE_TRIAGE_BOT_PAT}}
owner: VSCodeTriageBot
repo: testissues
destinationOwner: VSCodeTriageBot
destinationRepo: testissues

- name: Run New Release
if: github.event.issue.user.login != 'ghost'
Expand Down
76 changes: 40 additions & 36 deletions build/lib/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 41 additions & 36 deletions build/lib/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function emitEntryPoints(modules: IBuildModuleInfo[], entryPoints: IEntryPointMa

return {
// TODO@TS 2.1.2
files: extractStrings(removeDuplicateTSBoilerplate(result)),
files: extractStrings(removeAllDuplicateTSBoilerplate(result)),
bundleData: bundleData
};
}
Expand Down Expand Up @@ -350,7 +350,19 @@ function extractStrings(destFiles: IConcatFile[]): IConcatFile[] {
return destFiles;
}

function removeDuplicateTSBoilerplate(destFiles: IConcatFile[]): IConcatFile[] {
function removeAllDuplicateTSBoilerplate(destFiles: IConcatFile[]): IConcatFile[] {
destFiles.forEach((destFile) => {
const SEEN_BOILERPLATE: boolean[] = [];
destFile.sources.forEach((source) => {
source.contents = removeDuplicateTSBoilerplate(source.contents, SEEN_BOILERPLATE);
});
});

return destFiles;
}

export function removeDuplicateTSBoilerplate(source: string, SEEN_BOILERPLATE: boolean[] = []): string {

// Taken from typescript compiler => emitFiles
const BOILERPLATE = [
{ start: /^var __extends/, end: /^}\)\(\);$/ },
Expand All @@ -365,44 +377,37 @@ function removeDuplicateTSBoilerplate(destFiles: IConcatFile[]): IConcatFile[] {
{ start: /^var __importStar/, end: /^};$/ },
];

destFiles.forEach((destFile) => {
const SEEN_BOILERPLATE: boolean[] = [];
destFile.sources.forEach((source) => {
const lines = source.contents.split(/\r\n|\n|\r/);
const newLines: string[] = [];
let IS_REMOVING_BOILERPLATE = false, END_BOILERPLATE: RegExp;

for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (IS_REMOVING_BOILERPLATE) {
newLines.push('');
if (END_BOILERPLATE!.test(line)) {
IS_REMOVING_BOILERPLATE = false;
}
} else {
for (let j = 0; j < BOILERPLATE.length; j++) {
const boilerplate = BOILERPLATE[j];
if (boilerplate.start.test(line)) {
if (SEEN_BOILERPLATE[j]) {
IS_REMOVING_BOILERPLATE = true;
END_BOILERPLATE = boilerplate.end;
} else {
SEEN_BOILERPLATE[j] = true;
}
}
}
if (IS_REMOVING_BOILERPLATE) {
newLines.push('');
const lines = source.split(/\r\n|\n|\r/);
const newLines: string[] = [];
let IS_REMOVING_BOILERPLATE = false, END_BOILERPLATE: RegExp;

for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (IS_REMOVING_BOILERPLATE) {
newLines.push('');
if (END_BOILERPLATE!.test(line)) {
IS_REMOVING_BOILERPLATE = false;
}
} else {
for (let j = 0; j < BOILERPLATE.length; j++) {
const boilerplate = BOILERPLATE[j];
if (boilerplate.start.test(line)) {
if (SEEN_BOILERPLATE[j]) {
IS_REMOVING_BOILERPLATE = true;
END_BOILERPLATE = boilerplate.end;
} else {
newLines.push(line);
SEEN_BOILERPLATE[j] = true;
}
}
}
source.contents = newLines.join('\n');
});
});

return destFiles;
if (IS_REMOVING_BOILERPLATE) {
newLines.push('');
} else {
newLines.push(line);
}
}
}
return newLines.join('\n');
}

interface IPluginMap {
Expand Down
3 changes: 2 additions & 1 deletion extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"scmValidation",
"tabInputMultiDiff",
"tabInputTextMerge",
"timeline"
"timeline",
"quickInputButtonLocation"
],
"categories": [
"Other"
Expand Down
3 changes: 2 additions & 1 deletion extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as os from 'os';
import * as path from 'path';
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento, UIKind, QuickInputButton, ThemeIcon, SourceControlHistoryItem, SourceControl, InputBoxValidationMessage, Tab, TabInputNotebook } from 'vscode';
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento, UIKind, QuickInputButton, ThemeIcon, SourceControlHistoryItem, SourceControl, InputBoxValidationMessage, Tab, TabInputNotebook, QuickInputButtonLocation } from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
import { ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
Expand Down Expand Up @@ -2703,6 +2703,7 @@ export class CommandCenter {
{
iconPath: new ThemeIcon('refresh'),
tooltip: l10n.t('Regenerate Branch Name'),
location: QuickInputButtonLocation.Inline
}
] : [];

Expand Down
64 changes: 40 additions & 24 deletions extensions/git/src/historyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,16 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
this.currentHistoryItemGroup = {
id: `refs/heads/${this.repository.HEAD.name ?? ''}`,
name: this.repository.HEAD.name ?? '',
revision: this.repository.HEAD.commit ?? '',
remote: this.repository.HEAD.upstream ? {
id: `refs/remotes/${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
name: `${this.repository.HEAD.upstream.remote}/${this.repository.HEAD.upstream.name}`,
revision: this.repository.HEAD.upstream.commit ?? ''
} : undefined,
base: mergeBase ? {
id: `refs/remotes/${mergeBase.remote}/${mergeBase.name}`,
name: `${mergeBase.remote}/${mergeBase.name}`,
revision: mergeBase.commit ?? ''
} : undefined
};

Expand Down Expand Up @@ -132,26 +135,18 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
}

async provideHistoryItems2(options: SourceControlHistoryOptions): Promise<SourceControlHistoryItem[]> {
if (!this.currentHistoryItemGroup || !options.historyItemGroupIds) {
if (!this.currentHistoryItemGroup || !options.historyItemGroupIds || typeof options.limit === 'number' || !options.limit?.id) {
return [];
}

// Deduplicate refNames
const refNames = Array.from(new Set<string>(options.historyItemGroupIds));

// Get the merge base of the refNames
const refsMergeBase = await this.resolveHistoryItemGroupsMergeBase(refNames);
if (!refsMergeBase) {
return [];
}

const historyItems: SourceControlHistoryItem[] = [];

try {
// Get the common ancestor commit, and commits
const [mergeBaseCommit, commits] = await Promise.all([
this.repository.getCommit(refsMergeBase),
this.repository.log({ range: `${refsMergeBase}..`, refNames, shortStats: true })
this.repository.getCommit(options.limit.id),
this.repository.log({ range: `${options.limit.id}..`, refNames, shortStats: true })
]);

// Add common ancestor commit
Expand All @@ -161,7 +156,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec

await ensureEmojis();

historyItems.push(...commits.map(commit => {
return commits.map(commit => {
const newLineIndex = commit.message.indexOf('\n');
const subject = newLineIndex !== -1 ? commit.message.substring(0, newLineIndex) : commit.message;

Expand All @@ -177,12 +172,11 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
statistics: commit.shortStat ?? { files: 0, insertions: 0, deletions: 0 },
labels: labels.length !== 0 ? labels : undefined
};
}));
});
} catch (err) {
this.logger.error(`[GitHistoryProvider][provideHistoryItems2] Failed to get history items '${refsMergeBase}..': ${err}`);
this.logger.error(`[GitHistoryProvider][provideHistoryItems2] Failed to get history items '${options.limit.id}..': ${err}`);
return [];
}

return historyItems;
}

async provideHistoryItemSummary(historyItemId: string, historyItemParentId: string | undefined): Promise<SourceControlHistoryItem> {
Expand Down Expand Up @@ -260,17 +254,39 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
return undefined;
}

provideFileDecoration(uri: Uri): FileDecoration | undefined {
return this.historyItemDecorations.get(uri.toString());
}
async resolveHistoryItemGroupCommonAncestor2(historyItemGroupIds: string[]): Promise<string | undefined> {
try {
if (historyItemGroupIds.length === 0) {
// TODO@lszomoru - log
return undefined;
} else if (historyItemGroupIds.length === 1 && historyItemGroupIds[0] === this.currentHistoryItemGroup?.id) {
// Remote
if (this.currentHistoryItemGroup.remote) {
const ancestor = await this.repository.getMergeBase(historyItemGroupIds[0], this.currentHistoryItemGroup.remote.id);
return ancestor;
}

private async resolveHistoryItemGroupsMergeBase(refNames: string[]): Promise<string | undefined> {
if (refNames.length < 2) {
return undefined;
// Base
if (this.currentHistoryItemGroup.base) {
const ancestor = await this.repository.getMergeBase(historyItemGroupIds[0], this.currentHistoryItemGroup.base.id);
return ancestor;
}

// TODO@lszomoru - Return first commit
} else if (historyItemGroupIds.length > 1) {
const ancestor = await this.repository.getMergeBase(historyItemGroupIds[0], historyItemGroupIds[1], ...historyItemGroupIds.slice(2));
return ancestor;
}
}
catch (err) {
this.logger.error(`[GitHistoryProvider][resolveHistoryItemGroupCommonAncestor2] Failed to resolve common ancestor for ${historyItemGroupIds.join(',')}: ${err}`);
}

return undefined;
}

const refsMergeBase = await this.repository.getMergeBase(refNames[0], refNames[1], ...refNames.slice(2));
return refsMergeBase;
provideFileDecoration(uri: Uri): FileDecoration | undefined {
return this.historyItemDecorations.get(uri.toString());
}

private resolveHistoryItemLabels(commit: Commit, refNames: string[]): SourceControlHistoryItemLabel[] {
Expand Down
1 change: 1 addition & 0 deletions extensions/git/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"../../src/vscode-dts/vscode.proposed.tabInputMultiDiff.d.ts",
"../../src/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts",
"../../src/vscode-dts/vscode.proposed.timeline.d.ts",
"../../src/vscode-dts/vscode.proposed.quickInputButtonLocation.d.ts",
"../types/lib.textEncoder.d.ts"
]
}
Loading

0 comments on commit 8129f61

Please sign in to comment.