Skip to content

Commit 8c7b31f

Browse files
authored
Merge branch 'main' into tyriar/240249
2 parents 06483a8 + 14b1516 commit 8c7b31f

File tree

43 files changed

+347
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+347
-98
lines changed

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
disturl="https://electronjs.org/headers"
22
target="32.2.7"
3-
ms_build_id="10660205"
3+
ms_build_id="10982180"
44
runtime="electron"
55
build_from_source="true"
66
legacy-peer-deps="true"

extensions/git/package.json

+27
Original file line numberDiff line numberDiff line change
@@ -3297,6 +3297,33 @@
32973297
"maximum": 40,
32983298
"markdownDescription": "%config.commitShortHashLength%",
32993299
"scope": "resource"
3300+
},
3301+
"git.diagnosticsCommitHook.Severity": {
3302+
"type": "string",
3303+
"enum": [
3304+
"error",
3305+
"warning",
3306+
"information",
3307+
"hint"
3308+
],
3309+
"enumDescriptions": [
3310+
"%config.diagnosticsCommitHook.Severity.error%",
3311+
"%config.diagnosticsCommitHook.Severity.warning%",
3312+
"%config.diagnosticsCommitHook.Severity.information%",
3313+
"%config.diagnosticsCommitHook.Severity.hint%"
3314+
],
3315+
"default": "error",
3316+
"markdownDescription": "%config.diagnosticsCommitHook.Severity%",
3317+
"scope": "resource"
3318+
},
3319+
"git.diagnosticsCommitHook.Source": {
3320+
"type": "array",
3321+
"items": {
3322+
"type": "string"
3323+
},
3324+
"default": [],
3325+
"markdownDescription": "%config.diagnosticsCommitHook.Source%",
3326+
"scope": "resource"
33003327
}
33013328
}
33023329
},

extensions/git/package.nls.json

+6
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@
286286
"config.blameStatusBarItem.enabled": "Controls whether to show blame information in the status bar.",
287287
"config.blameStatusBarItem.template": "Template for the blame information status bar item. Supported variables:\n\n* `hash`: Commit hash\n\n* `hashShort`: First N characters of the commit hash according to `#git.commitShortHashLength#`\n\n* `subject`: First line of the commit message\n\n* `authorName`: Author name\n\n* `authorEmail`: Author email\n\n* `authorDate`: Author date\n\n* `authorDateAgo`: Time difference between now and the author date\n\n",
288288
"config.commitShortHashLength": "Controls the length of the commit short hash.",
289+
"config.diagnosticsCommitHook.Severity": "Controls the minimum diagnostics severity for which Git should check before committing.",
290+
"config.diagnosticsCommitHook.Severity.error": "Errors only",
291+
"config.diagnosticsCommitHook.Severity.warning": "Errors and warnings",
292+
"config.diagnosticsCommitHook.Severity.information": "Errors, warnings, and information",
293+
"config.diagnosticsCommitHook.Severity.hint": "Errors, warnings, information, and hints",
294+
"config.diagnosticsCommitHook.Source": "Controls the list of diagnostics sources for which Git should check before committing.",
289295
"submenu.explorer": "Git",
290296
"submenu.commit": "Commit",
291297
"submenu.commit.amend": "Amend",

extensions/git/src/commands.ts

+69-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as os from 'os';
77
import * as path from 'path';
8-
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';
8+
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, languages } from 'vscode';
99
import TelemetryReporter from '@vscode/extension-telemetry';
1010
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
1111
import { ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
@@ -14,7 +14,7 @@ import { Model } from './model';
1414
import { GitResourceGroup, Repository, Resource, ResourceGroupType } from './repository';
1515
import { DiffEditorSelectionHunkToolbarContext, applyLineChanges, getIndexDiffInformation, getModifiedRange, getWorkingTreeDiffInformation, intersectDiffWithRange, invertLineChange, toLineChanges, toLineRanges } from './staging';
1616
import { fromGitUri, toGitUri, isGitUri, toMergeUris, toMultiFileDiffEditorUris } from './uri';
17-
import { dispose, getCommitShortHash, grep, isDefined, isDescendant, pathEquals, relativePath, truncate } from './util';
17+
import { DiagnosticSeverityConfig, dispose, getCommitShortHash, grep, isDefined, isDescendant, pathEquals, relativePath, toDiagnosticSeverity, truncate } from './util';
1818
import { GitTimelineItem } from './timelineProvider';
1919
import { ApiRepository } from './api/api1';
2020
import { getRemoteSourceActions, pickRemoteSource } from './remoteSource';
@@ -617,6 +617,66 @@ class CommandErrorOutputTextDocumentContentProvider implements TextDocumentConte
617617
}
618618
}
619619

620+
async function evaluateDiagnosticsCommitHook(repository: Repository, options: CommitOptions): Promise<boolean> {
621+
const config = workspace.getConfiguration('git', Uri.file(repository.root));
622+
const diagnosticSource = config.get<string[]>('diagnosticsCommitHook.Source', []);
623+
const diagnosticSeveritySetting = config.get<DiagnosticSeverityConfig>('diagnosticsCommitHook.Severity', 'error');
624+
const diagnosticSeverity = toDiagnosticSeverity(diagnosticSeveritySetting);
625+
626+
if (diagnosticSource.length === 0) {
627+
return true;
628+
}
629+
630+
const changes: Uri[] = [];
631+
if (repository.indexGroup.resourceStates.length > 0) {
632+
// Staged files
633+
changes.push(...repository.indexGroup.resourceStates.map(r => r.resourceUri));
634+
} else if (options.all === 'tracked') {
635+
// Tracked files
636+
changes.push(...repository.workingTreeGroup.resourceStates
637+
.filter(r => r.type !== Status.UNTRACKED && r.type !== Status.IGNORED)
638+
.map(r => r.resourceUri));
639+
} else {
640+
// All files
641+
changes.push(...repository.workingTreeGroup.resourceStates.map(r => r.resourceUri));
642+
changes.push(...repository.untrackedGroup.resourceStates.map(r => r.resourceUri));
643+
}
644+
645+
const diagnostics = languages.getDiagnostics();
646+
const changesDiagnostics = diagnostics.filter(([uri, diags]) =>
647+
// File
648+
changes.some(u => uri.scheme === 'file' && pathEquals(u.fsPath, uri.fsPath)) &&
649+
// Severity
650+
diags.some(d => d.source && diagnosticSource.includes(d.source) && d.severity <= diagnosticSeverity)
651+
);
652+
653+
if (changesDiagnostics.length === 0) {
654+
return true;
655+
}
656+
657+
// Show dialog
658+
const commit = l10n.t('Commit Anyway');
659+
const view = l10n.t('View Problems');
660+
661+
const message = changesDiagnostics.length === 1
662+
? l10n.t('The following file has unresolved diagnostic information: {0}.\n\nHow would you like to proceed?', path.basename(changesDiagnostics[0][0].fsPath))
663+
: l10n.t('There are {0} files that have unresolved diagnostic information.\n\nHow would you like to proceed?', changesDiagnostics.length);
664+
665+
const choice = await window.showWarningMessage(message, { modal: true }, commit, view);
666+
667+
// Commit Anyway
668+
if (choice === commit) {
669+
return true;
670+
}
671+
672+
// View Problems
673+
if (choice === view) {
674+
commands.executeCommand('workbench.panel.markers.view.focus');
675+
}
676+
677+
return false;
678+
}
679+
620680
export class CommandCenter {
621681

622682
private disposables: Disposable[];
@@ -2273,7 +2333,13 @@ export class CommandCenter {
22732333
opts.all = 'tracked';
22742334
}
22752335

2276-
// Branch protection
2336+
// Diagnostics commit hook
2337+
const diagnosticsResult = await evaluateDiagnosticsCommitHook(repository, opts);
2338+
if (!diagnosticsResult) {
2339+
return;
2340+
}
2341+
2342+
// Branch protection commit hook
22772343
const branchProtectionPrompt = config.get<'alwaysCommit' | 'alwaysCommitToNewBranch' | 'alwaysPrompt'>('branchProtectionPrompt')!;
22782344
if (repository.isBranchProtected() && (branchProtectionPrompt === 'alwaysPrompt' || branchProtectionPrompt === 'alwaysCommitToNewBranch')) {
22792345
const commitToNewBranch = l10n.t('Commit to a New Branch');

extensions/git/src/util.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef, l10n, workspace, Uri } from 'vscode';
6+
import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef, l10n, workspace, Uri, DiagnosticSeverity } from 'vscode';
77
import { dirname, sep, relative } from 'path';
88
import { Readable } from 'stream';
99
import { promises as fs, createReadStream } from 'fs';
@@ -772,3 +772,15 @@ export function getCommitShortHash(scope: Uri, hash: string): string {
772772
const shortHashLength = config.get<number>('commitShortHashLength', 7);
773773
return hash.substring(0, shortHashLength);
774774
}
775+
776+
export type DiagnosticSeverityConfig = 'error' | 'warning' | 'information' | 'hint';
777+
778+
export function toDiagnosticSeverity(value: DiagnosticSeverityConfig): DiagnosticSeverity {
779+
return value === 'error'
780+
? DiagnosticSeverity.Error
781+
: value === 'warning'
782+
? DiagnosticSeverity.Warning
783+
: value === 'information'
784+
? DiagnosticSeverity.Information
785+
: DiagnosticSeverity.Hint;
786+
}

extensions/github-authentication/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
}
4040
],
4141
"configuration": [{
42-
"title": "GitHub Enterprise Server Authentication Provider",
42+
"title": "%config.github-enterprise.title%",
4343
"properties": {
4444
"github-enterprise.uri": {
4545
"type": "string",
46-
"description": "GitHub Enterprise Server URI"
46+
"markdownDescription": "%config.github-enterprise.uri.description%",
47+
"pattern": "^(?:$|(https?)://(?!github\\.com).*)"
4748
}
4849
}
4950
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"displayName": "GitHub Authentication",
3-
"description": "GitHub Authentication Provider"
3+
"description": "GitHub Authentication Provider",
4+
"config.github-enterprise.title": "GHE.com & GitHub Enterprise Server Authentication",
5+
"config.github-enterprise.uri.description": "The URI for your GHE.com or GitHub Enterprise Server instance.\n\nExamples:\n* GHE.com: `https://octocat.ghe.com`\n* GitHub Enterprise Server: `https://github.octocat.com`\n\n> **Note:** This should _not_ be set to a GitHub.com URI. If your account exists on GitHub.com or is a GitHub Enterprise Managed User, you do not need any additional configuration and can simply log in to GitHub."
46
}

extensions/terminal-suggest/src/terminalSuggestMain.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,17 @@ export async function collectCompletionItemResult(command: Command, parsedArgume
289289
if (!specArgs) {
290290
return { filesRequested, foldersRequested };
291291
}
292-
292+
const flagsToExclude = kind === vscode.TerminalCompletionItemKind.Flag ? parsedArguments?.passedOptions.map(option => option.name).flat() : undefined;
293293
if (Array.isArray(specArgs)) {
294294
for (const item of specArgs) {
295295
const suggestionLabels = getLabel(item);
296-
if (!suggestionLabels) {
296+
if (!suggestionLabels?.length) {
297297
continue;
298298
}
299299
for (const label of suggestionLabels) {
300+
if (flagsToExclude?.includes(label)) {
301+
continue;
302+
}
300303
items.push(
301304
createCompletionItem(
302305
terminalContext.cursorPosition,
@@ -311,6 +314,9 @@ export async function collectCompletionItemResult(command: Command, parsedArgume
311314
}
312315
} else {
313316
for (const [label, item] of Object.entries(specArgs)) {
317+
if (flagsToExclude?.includes(label)) {
318+
continue;
319+
}
314320
items.push(
315321
createCompletionItem(
316322
terminalContext.cursorPosition,
@@ -332,7 +338,7 @@ export async function collectCompletionItemResult(command: Command, parsedArgume
332338
await addSuggestions(parsedArguments.completionObj.subcommands, vscode.TerminalCompletionItemKind.Method);
333339
}
334340
if (parsedArguments.suggestionFlags & SuggestionFlag.Options) {
335-
await addSuggestions(parsedArguments.completionObj.options, vscode.TerminalCompletionItemKind.Flag);
341+
await addSuggestions(parsedArguments.completionObj.options, vscode.TerminalCompletionItemKind.Flag, parsedArguments);
336342
}
337343

338344
return { filesRequested, foldersRequested };
@@ -363,6 +369,7 @@ export async function getCompletionItemsFromSpecs(
363369
}
364370
}
365371

372+
let hasCurrentArg = false;
366373
for (const spec of specs) {
367374
const specLabels = getLabel(spec);
368375

@@ -407,7 +414,7 @@ export async function getCompletionItemsFromSpecs(
407414
{ environmentVariables: env, currentWorkingDirectory: shellIntegrationCwd.fsPath, sshPrefix: '', currentProcess: name, /* TODO: pass in aliases */ },
408415
spec,
409416
);
410-
417+
hasCurrentArg ||= !!parsedArguments.currentArg;
411418
const completionItemResult = await collectCompletionItemResult(command, parsedArguments, prefix, terminalContext, items);
412419
if (completionItemResult) {
413420
filesRequested ||= completionItemResult.filesRequested;
@@ -426,7 +433,7 @@ export async function getCompletionItemsFromSpecs(
426433
}
427434
filesRequested = true;
428435
foldersRequested = true;
429-
} else if (!items.length && !filesRequested && !foldersRequested) {
436+
} else if (!items.length && !filesRequested && !foldersRequested && !hasCurrentArg) {
430437
// Not a command and no specific args or options were provided, so show resources
431438
filesRequested = true;
432439
foldersRequested = true;

extensions/terminal-suggest/src/test/completions/code.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export function createCodeTestSpecs(executable: string): ITestSpec[] {
3535
{ input: `${executable} --merge ./file1 ./file2 ./base |`, expectedResourceRequests: { type: 'files', cwd: testPaths.cwd } },
3636
{ input: `${executable} --goto |`, expectedResourceRequests: { type: 'files', cwd: testPaths.cwd } },
3737
{ input: `${executable} --user-data-dir |`, expectedResourceRequests: { type: 'folders', cwd: testPaths.cwd } },
38-
{ input: `${executable} --profile |`, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
39-
{ input: `${executable} --install-extension |`, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
40-
{ input: `${executable} --uninstall-extension |`, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
38+
{ input: `${executable} --profile |` },
39+
{ input: `${executable} --install-extension |` },
40+
{ input: `${executable} --uninstall-extension |` },
4141
{ input: `${executable} --log |`, expectedCompletions: logOptions },
4242
{ input: `${executable} --sync |`, expectedCompletions: syncOptions },
4343
{ input: `${executable} --extensions-dir |`, expectedResourceRequests: { type: 'folders', cwd: testPaths.cwd } },
44-
{ input: `${executable} --list-extensions |`, expectedCompletions: codeSpecOptions, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
45-
{ input: `${executable} --show-versions |`, expectedCompletions: codeSpecOptions, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
44+
{ input: `${executable} --list-extensions |`, expectedCompletions: codeSpecOptions.filter(c => c !== '--list-extensions'), expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
45+
{ input: `${executable} --show-versions |`, expectedCompletions: codeSpecOptions.filter(c => c !== '--show-versions'), expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
4646
{ input: `${executable} --category |`, expectedCompletions: categoryOptions },
4747
{ input: `${executable} --category a|`, expectedCompletions: categoryOptions },
4848

extensions/terminal-suggest/src/test/completions/upstream/ls.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ export const lsTestSuiteSpec: ISuiteSpec = {
7272
{ input: 'ls -a|', expectedCompletions: allOptions },
7373

7474
// Duplicate option
75-
// TODO: Duplicate options should not be presented https://github.com/microsoft/vscode/issues/239607
76-
// { input: 'ls -a -|', expectedCompletions: removeArrayEntry(allOptions, '-a'), expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
75+
{ input: 'ls -a -|', expectedCompletions: allOptions.filter(o => o !== '-a'), expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
7776

7877
// Relative paths
7978
{ input: 'ls c|', expectedCompletions: allOptions, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
@@ -89,3 +88,4 @@ export const lsTestSuiteSpec: ISuiteSpec = {
8988
{ input: 'ls ../sibling|', expectedCompletions: allOptions, expectedResourceRequests: { type: 'both', cwd: testPaths.cwdParent } },
9089
]
9190
};
91+

extensions/terminal-suggest/src/test/fig.test.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ export const figGenericTestSuites: ISuiteSpec[] = [
9393
testSpecs: [
9494
{ input: 'foo |', expectedCompletions: ['--bar', '--baz'] },
9595
{ input: 'foo bar|', expectedCompletions: ['--bar', '--baz'] },
96-
// TODO: Duplicate options should not be presented https://github.com/microsoft/vscode/issues/239607
97-
// { input: 'foo --bar |', expectedCompletions: ['--baz'] },
98-
// { input: 'foo --baz |', expectedCompletions: ['--bar'] },
96+
{ input: 'foo --bar |', expectedCompletions: ['--baz'] },
97+
{ input: 'foo --baz |', expectedCompletions: ['--bar'] },
9998
]
10099
},
101100
{
@@ -124,10 +123,9 @@ export const figGenericTestSuites: ISuiteSpec[] = [
124123
testSpecs: [
125124
{ input: 'foo |', expectedCompletions: ['--bar'] },
126125
{ input: 'foo --bar |', expectedCompletions: ['a', 'b', 'c'] },
127-
// TODO: All options should be suggested here? https://github.com/microsoft/vscode/issues/239713
128-
// { input: 'foo --bar a|', expectedCompletions: ['a', 'b', 'c'] },
129-
// { input: 'foo --bar b|', expectedCompletions: ['a', 'b', 'c'] },
130-
// { input: 'foo --bar c|', expectedCompletions: ['a', 'b', 'c'] },
126+
{ input: 'foo --bar a|', expectedCompletions: ['a', 'b', 'c'] },
127+
{ input: 'foo --bar b|', expectedCompletions: ['a', 'b', 'c'] },
128+
{ input: 'foo --bar c|', expectedCompletions: ['a', 'b', 'c'] },
131129
]
132130
}
133131
];

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-oss-dev",
33
"version": "1.98.0",
4-
"distro": "8003b9520817bc4fb7e06779aaca5f9e2f730e98",
4+
"distro": "7101cb2245e859d8c5f4b60971ca7d2e9dcca7dd",
55
"author": {
66
"name": "Microsoft Corporation"
77
},
@@ -74,7 +74,7 @@
7474
"@types/semver": "^7.5.8",
7575
"@vscode/deviceid": "^0.1.1",
7676
"@vscode/iconv-lite-umd": "0.7.0",
77-
"@vscode/policy-watcher": "^1.1.9",
77+
"@vscode/policy-watcher": "^1.1.10",
7878
"@vscode/proxy-agent": "^0.31.0",
7979
"@vscode/ripgrep": "^1.15.10",
8080
"@vscode/spdlog": "^0.15.0",

0 commit comments

Comments
 (0)