diff --git a/rust/contracts/rust-core-api.md b/rust/contracts/rust-core-api.md index 0c2afc0c..df9e4ba1 100644 --- a/rust/contracts/rust-core-api.md +++ b/rust/contracts/rust-core-api.md @@ -718,7 +718,7 @@ or removing a command fails until the table changes in the same commit. | `git.changelists` | Reduce local ChangeList metadata and project membership and commit scope | | `git.shelf` | Capture or applies one guarded Shelf layer | | `git.commitMessageContext` | Capture bounded AI commit evidence and recheck its Git state | -| `git.consolePresentation` | Pure IDEA-style configuration/progress folds, empty-output notices and search ranges over retained diagnostic snapshots | +| `git.consolePresentation` | Pure IDEA-style configuration/progress/query folds, empty-output notices and search ranges over retained diagnostic snapshots, shaped by the console's display choices | | `git.remoteUrl` | Read a configured remote URL silently; a missing remote returns a null URL | | `git.fetchPlan` | Validate Fetch choices; optionally inspect a repository to expand enabled per-remote commands | | `git.executable` | Resolve the executable Git will run without requiring a repository | @@ -1060,8 +1060,9 @@ is active; it does not wait behind a mutex outside its cancellation deadline. Git requests may include optional envelope metadata `gitExecution`: `{ executable?: string | null, interactive?: boolean, useCredentialHelper?: boolean, fetchDefaults?: GitFetchOptions, detailedFetch?: boolean, source?: "user" | "background" | "unknown", -reportQueries?: boolean }`. Defaults are PATH, noninteractive, helper enabled, normal -Fetch defaults, legacy Fetch results, and silent internal queries. +consoleQueries?: QueryCategory[], queryCategory?: QueryCategory }`. Defaults are PATH, +noninteractive, helper enabled, normal Fetch defaults, legacy Fetch results, and no +recorded query category, which leaves every internal query silent as IDEA does. An executable must be an absolute native path to Git 2.31 or newer. Interactive commands require an event receiver. These values are request-scoped, including nested requests, and never implicitly persist. Both current applications opt @@ -1180,7 +1181,7 @@ Each event has `operationId` and `type`: | Type | Additional fields | | --- | --- | | `requestStarted` | none; cancellation is registered before delivery | -| `started` | `invocationId`, `workingDirectory`, `arguments`, nullable resolved `executable`, `temporaryConfig` key/value pairs, `displayArguments`, `globalArguments`, `source`, `query` | +| `started` | `invocationId`, `workingDirectory`, `arguments`, nullable resolved `executable`, `temporaryConfig` key/value pairs, `displayArguments`, `globalArguments`, `source`, `query`, and a query's `queryCategory` when it has one | | `output` | `invocationId`, `stream` (`stdout`/`stderr`), `text`, `progress`, `truncated`, optional `progressDetails` (`stage`, nullable `percent`, `completed`, `total`) | | `finished` | `invocationId`, nullable `exitCode`, monotonic `durationMilliseconds`, nullable `error`, `expectedExit` | | `requestFinished` | nullable `error`, including failures before a child started; `unconfirmedInvocations`, the started records without `finished`; `failureRecord`, true when `error` is set, is not a cancellation, and no record of the request failed or is unconfirmed, so the host shows the error as its own record | @@ -1196,7 +1197,7 @@ Native journals track `requestStarted` separately from visible command records. The native receiver retains the originating request directory so a failure before `started` can be shown as an unconfirmed request with no fabricated arguments or exit code. Successfully completed internal queries still produce no history row -unless they were reported through `gitExecution.reportQueries`. +unless their category is one the request's `gitExecution.consoleQueries` records. A request that ends with the `cancelled` error before any command started was superseded, not a Git failure, and also produces no row; a cancelled request that had started a command keeps that command with the cancellation as its reason. @@ -1213,6 +1214,33 @@ Notices require empty retained output, no progress, no truncation and no failure zero `updatedReferenceCount` and `deletedReferenceCount`. Missing counts must not be treated as zero. Other successful empty results use `completedWithoutOutput`. +`git.consolePresentation` accepts `{ records, search?: string, display?: { foldShortQueries?: +boolean, showCompletedWithoutOutput?: boolean, hideTemporaryConfig?: boolean, +hideRepository?: boolean } }`. Every display choice defaults to `false`, which is IDEA's +console: a query that wrote ten lines or fewer keeps them visible, `completedWithoutOutput` +is omitted (IDEA prints nothing after an empty command; `waitingForOutput` and +`fetchUnchanged` stay), temporary `-c` configuration is folded rather than left out, and each +entry is labelled with its repository. `foldShortQueries` folds a successful query's output +at any length. `hideTemporaryConfig` leaves Core's temporary configuration out of the command +fragments; `-c` pairs in the operation's own arguments still fold in place. `hideRepository` +returns an empty `repositoryLabel` and excludes the repository from search. A host persists +these as console preferences; they never change the retained records or copied commands. + +Output folds only when it is longer than ten lines: a contiguous block of Git progress lines +(IDEA's progress grammar, remote phases included) becomes one `progress` fragment once it has +more than ten lines, and shorter blocks stay `text`. A failed record folds no output. A record +whose arguments delete something folds nothing at all, neither its `-c` configuration nor its +progress nor a query's output, whatever the display choices, so the console shows everything +a deletion ran with and reported; `hideTemporaryConfig` still leaves the temporary +configuration out. Deleting means, after the global options: `rm` and `clean` (a dry-run +`clean -n` lists what a clean deletes); `branch`, `tag`, `update-ref` or `symbolic-ref` with +`-d`, `-D` or `--delete`; `push` with `-d`, `--delete`, `--prune` or a refspec without a +source (`:refs/heads/topic`); `fetch` or `pull` with `-p`, `--prune`, `-P` or `--prune-tags`; +`remote remove`, `remote rm`, `remote prune` and `remote update --prune`; `config` with +`--unset`, `--unset-all`, `--remove-section`, `unset` or `remove-section`; `stash drop`, +`stash clear` and `stash pop`; and `worktree remove` and `worktree prune`. Only options +before `--` count. See the `deletions` table of `rust/fixtures/git/console-presentation-v1.json`. + `displayArguments` and `globalArguments` are additive console projections: the former starts at the subcommand, and the latter contains temporary configuration as `-c key=value` pairs followed by the original global argument prefix. Consoles @@ -1220,18 +1248,44 @@ fold contiguous `-c` pairs at their original positions; other global arguments stay visible. Raw `arguments` remain authoritative for copying and diagnostics. Older events without projections retain their legacy display. Visible workflow commands and explicit `git.command` requests produce execution events. Internal read-only queries remain silent in the console while retaining -normal workflow capture and result semantics, unless the request sets -`gitExecution.reportQueries`: then each query produces the same `started`, `output` -and `finished` events as a visible command, so the console records what the -workbench read. Their `started` event carries `query: true`; every visible command +normal workflow capture and result semantics, unless `gitExecution.consoleQueries` +records the request's query category: then each query produces the same `started`, +`output` and `finished` events as a visible command, so the console records what the +workbench read. A query category is `references` (background branch reads such as nested +repository references), `reload` (reads after an operation completes), `diffRefresh` +(reloading an open diff after a save), `diff`, `log`, `logPathFilter` (per-commit file +reads that filter the log by path), `annotate`, `panels` (worktree, stash, remote and +similar lists), or `checks` (pre-operation checks). The category is +`gitExecution.queryCategory` when the host names one for reads the command alone does not +tell apart; otherwise Core derives it from the request command: `diff` for `git.diff`, +`git.comparison` and `git.planDiffBlocks`; `log` for history, reference, tag, commit and +graph reads; `annotate` for `git.blame` and `git.lineHistory`; `panels` for worktree, +stash, remote, pull request, untracked directory, repository setup and execution inspection +reads; and `checks` for every other Git command. Commands outside Git have no category, and +neither have the queries of a `background` request that names none. The `queryCategories` +list of the fixture below names every category; `gitExecution` rejects any other name. A +reported query's `started` event carries its `queryCategory`, so a host that stops +recording a category can drop the successful queries of it that it kept; a visible command, +and a query of no category, carries none. +A query whose category the console does not record emits no events while it succeeds, so it +never consumes the console's capacity. If it fails (an error, or a nonzero exit that does not +answer its question) in a request whose provenance is not `background`, Core sends its +`started` event (`query: true`), its stderr lines and its `finished` event together once it +ends, so the console shows the command, diagnostics and exit that failed; its stdout is not +kept, and the request then needs no `failureRecord`. A cancelled query reports nothing, and a +background request's unrecorded queries stay silent even when they fail. See +`rust/fixtures/git/console-queries-v1.json`. +A reported query's `started` event carries `query: true`; every visible command carries `query: false`. A host passes the flag back as the console record's `query`, and `git.consolePresentation` then folds a query's whole output into one `query` output fragment whose `count` labels it, the way IDEA keeps silent -handlers out of sight. A failed query and a query that wrote a single line keep -their output visible. Search still counts and locates every folded line, so a -host opens the fold on a hit. Queries of a request whose provenance is `background` (an -automatic refresh or watcher, which runs too often to record) stay silent even -then; provenance is `gitExecution.source`, or the envelope origin when that is +handlers out of sight. A failed query keeps its output visible, and so does a query +that wrote ten lines or fewer unless `display.foldShortQueries` is set, or a query that +deletes, such as `clean -n`. Search still +counts and locates every folded line, so a host opens the fold on a hit. Queries of a +request whose provenance is `background` (an automatic refresh or watcher, which runs too +often to record) stay silent unless the host names their `queryCategory`; +provenance is `gitExecution.source`, or the envelope origin when that is unknown. Reported queries never authenticate or prompt; a query that needs credentials fails as it does when silent. A query whose nonzero exit answers its question, such as a missing optional config value, an absent ref or a path outside diff --git a/rust/crates/core/src/runtime/dispatcher.rs b/rust/crates/core/src/runtime/dispatcher.rs index deb5bbe5..190ee0cb 100644 --- a/rust/crates/core/src/runtime/dispatcher.rs +++ b/rust/crates/core/src/runtime/dispatcher.rs @@ -146,7 +146,11 @@ fn execute_parsed(mut parsed: CoreRequest, document: Option<&str>) -> CoreRespon Ok(scope) => scope, Err(error) => return CoreResponse::failure(id, error), }; - let _git_policy = match lithe_git::execution_policy::Scope::begin(parsed.git_execution) { + let _git_policy = match lithe_git::execution_policy::Scope::begin( + parsed + .git_execution + .map(|options| options.for_command(&parsed.command)), + ) { Ok(scope) => scope, Err(error) => return CoreResponse::failure(id, error), }; diff --git a/rust/crates/core/src/tests/git_workspace_commit.rs b/rust/crates/core/src/tests/git_workspace_commit.rs index 333a311f..9578ab36 100644 --- a/rust/crates/core/src/tests/git_workspace_commit.rs +++ b/rust/crates/core/src/tests/git_workspace_commit.rs @@ -74,9 +74,9 @@ fn reported_queries(root: &Path, command: &str, git_execution: Value) -> Vec::new() ); - let refresh = json!({"reportQueries": true, "source": "background"}); + let other = json!({"consoleQueries": ["log"], "source": "user"}); + assert_eq!( + reported_queries(&repo.0, command, other), + Vec::::new() + ); + let refresh = json!({"consoleQueries": ["checks"], "source": "background"}); assert_eq!( reported_queries(&repo.0, command, refresh), Vec::::new() ); - let user = json!({"reportQueries": true, "source": "user"}); + let user = json!({"consoleQueries": ["checks"], "source": "user"}); let events = reported_queries(&repo.0, command, user); let started: Vec<_> = events.iter().filter(|e| e["type"] == "started").collect(); let finished: Vec<_> = events.iter().filter(|e| e["type"] == "finished").collect(); @@ -115,7 +120,7 @@ fn git_reported_status_shows_each_record_on_its_own_line() { fs::write(repo.0.join("first.txt"), "first").unwrap(); fs::write(repo.0.join("second.txt"), "second").unwrap(); - let events = reported_queries(&repo.0, "git.status", json!({"reportQueries": true})); + let events = reported_queries(&repo.0, "git.status", json!({"consoleQueries": ["checks"]})); let status = events .iter() .find(|e| { diff --git a/rust/crates/git/src/console/category.rs b/rust/crates/git/src/console/category.rs new file mode 100644 index 00000000..7dff0c2c --- /dev/null +++ b/rust/crates/git/src/console/category.rs @@ -0,0 +1,37 @@ +//! The console category of each Git request command's internal queries. +use super::types::QueryCategory; + +/// The category a request command's internal queries read, or `None` outside Git. Commands +/// that only show what Git has go by what they show; previews, preflights, plans and the +/// operations themselves are checks, so a command not listed here counts as one. +pub fn of_command(command: &str) -> Option { + use QueryCategory::*; + let category = match command { + "git.diff" | "git.comparison" | "git.planDiffBlocks" => Diff, + "git.history" + | "git.historyQuery" + | "git.historyPage" + | "git.historyWindow" + | "git.historyLocate" + | "git.historyActionCapabilities" + | "git.references" + | "git.referenceTree" + | "git.graphProjection" + | "git.tags" + | "git.commit" + | "git.commitFiles" + | "git.changedFileGroups" => Log, + "git.blame" | "git.lineHistory" => Annotate, + "git.worktrees" + | "git.stashes" + | "git.remotes" + | "git.remoteUrl" + | "git.pullRequestContext" + | "git.untrackedDirectory" + | "git.repositorySetup" + | "git.executionInspect" => Panels, + command if command.starts_with("git.") => Checks, + _ => return None, + }; + Some(category) +} diff --git a/rust/crates/git/src/console/command.rs b/rust/crates/git/src/console/command.rs index ab804866..32351d34 100644 --- a/rust/crates/git/src/console/command.rs +++ b/rust/crates/git/src/console/command.rs @@ -1,5 +1,5 @@ //! Conservative command compression: behavior-changing flags always remain visible. -use super::types::{CommandFragment, Record}; +use super::types::{CommandFragment, Display, Record}; use crate::execution_policy::command_index; pub(super) fn quote(value: &str) -> String { @@ -22,13 +22,21 @@ fn join(values: &[String]) -> String { } /// Fold contiguous Git configuration arguments in place, as IDEA's console does. /// Token boundaries preserve quoted values and avoid folding behavior flags or paths. -pub(super) fn project(record: &Record) -> Vec { +/// Hidden temporary configuration is left out; the arguments themselves always stay. +/// A command that `deletes` keeps its configuration open, so nothing of it hides. +pub(super) fn project(record: &Record, display: &Display, deletes: bool) -> Vec { let mut args = Vec::new(); - for (key, value) in &record.temporary_config { - args.extend(["-c".into(), format!("{key}={value}")]); + if !display.hide_temporary_config { + for (key, value) in &record.temporary_config { + args.extend(["-c".into(), format!("{key}={value}")]); + } } args.extend_from_slice(&record.arguments); - let command = command_index(&args).unwrap_or(0); + let command = if deletes { + 0 + } else { + command_index(&args).unwrap_or(0) + }; let mut result = Vec::new(); let mut index = 0; while index < args.len() { diff --git a/rust/crates/git/src/console/deletion.rs b/rust/crates/git/src/console/deletion.rs new file mode 100644 index 00000000..63c0253d --- /dev/null +++ b/rust/crates/git/src/console/deletion.rs @@ -0,0 +1,71 @@ +//! Commands that delete something stay unfolded, so the console shows all a deletion did. +use crate::execution_policy::command_index; + +/// Whether `arguments` delete branches, tags, references, remote branches, configuration, +/// files, stashes or worktrees, or list what a clean would delete. The console folds none +/// of such a command's configuration or output. Global options before the subcommand are +/// skipped, and only options before `--` count, so a path named like an option is a path. +pub(super) fn deletes(arguments: &[String]) -> bool { + let Some(index) = command_index(arguments) else { + return false; + }; + let rest = &arguments[index + 1..]; + let has = |names: &[&str]| { + rest.iter() + .take_while(|argument| argument.as_str() != "--") + .any(|argument| names.contains(&argument.as_str())) + }; + let action = rest + .iter() + .find(|argument| !argument.starts_with('-')) + .map(String::as_str); + match arguments[index].as_str() { + // A dry-run clean lists what a clean deletes, so it is shown whole as well. + "rm" | "clean" => true, + "branch" | "tag" | "update-ref" | "symbolic-ref" => has(&["-d", "-D", "--delete"]), + // A refspec without a source, `:refs/heads/topic`, deletes the remote branch. + "push" => { + has(&["-d", "--delete", "--prune"]) + || rest + .iter() + .any(|argument| argument.starts_with(':') && argument.len() > 1) + } + "fetch" | "pull" => has(&["-p", "--prune", "-P", "--prune-tags"]), + "remote" => { + matches!(action, Some("remove" | "rm" | "prune")) + || (action == Some("update") && has(&["-p", "--prune"])) + } + "config" => { + has(&["--unset", "--unset-all", "--remove-section"]) + || matches!(action, Some("unset" | "remove-section")) + } + // `pop` drops the entry it applied. + "stash" => matches!(action, Some("drop" | "clear" | "pop")), + "worktree" => matches!(action, Some("remove" | "prune")), + _ => false, + } +} + +#[cfg(test)] +mod tests { + use super::deletes; + use serde_json::Value; + + #[test] + fn deletions_match_the_shared_console_cases() { + let fixture: Value = serde_json::from_str(include_str!( + "../../../../fixtures/git/console-presentation-v1.json" + )) + .unwrap(); + let cases = fixture["deletions"].as_array().unwrap(); + assert!(!cases.is_empty()); + for case in cases { + let arguments: Vec = serde_json::from_value(case["arguments"].clone()).unwrap(); + assert_eq!( + deletes(&arguments), + case["deletes"].as_bool().unwrap(), + "{arguments:?}" + ); + } + } +} diff --git a/rust/crates/git/src/console/mod.rs b/rust/crates/git/src/console/mod.rs index f74bdb9c..d80e5179 100644 --- a/rust/crates/git/src/console/mod.rs +++ b/rust/crates/git/src/console/mod.rs @@ -1,12 +1,14 @@ //! Shared IDEA-style Git console folding and search over retained command text. +pub mod category; mod command; +mod deletion; mod output; #[cfg(test)] mod tests; mod types; use lithe_protocol::{CoreError, ErrorCode}; use types::*; -pub use types::{Request, Source}; +pub use types::{QueryCategory, Request, Source}; /// Generates a lossless display plan from already-retained, sanitized native records. /// Folded ranges always refer to the input; this operation never launches a process. @@ -54,24 +56,34 @@ pub fn present(request: Request) -> Result { total_matches: 0, }; let query = request.search.to_lowercase(); + let display = &request.display; for record in &request.records { let previous_matches = presentation.total_matches; + let deletes = deletion::deletes(&record.arguments); let mut entry = Entry { id: record.id.clone(), - repository_label: record.root.clone(), - command: command::project(record), - output: output::project(record), + repository_label: if display.hide_repository { + String::new() + } else { + record.root.clone() + }, + command: command::project(record, display, deletes), + output: output::project(record, display, deletes), failed: record.failed(), - notice: record.notice(), + notice: record.notice().filter(|notice| { + display.show_completed_without_output || *notice != Notice::CompletedWithoutOutput + }), }; if !query.is_empty() { - add_matches( - &mut presentation, - record, - "repository", - None, - occurrences(&record.root, &query), - ); + if !display.hide_repository { + add_matches( + &mut presentation, + record, + "repository", + None, + occurrences(&record.root, &query), + ); + } for fragment in &mut entry.command { fragment.matches = occurrences(&fragment.text, &query); add_matches( diff --git a/rust/crates/git/src/console/output.rs b/rust/crates/git/src/console/output.rs index ba9f12cb..50426408 100644 --- a/rust/crates/git/src/console/output.rs +++ b/rust/crates/git/src/console/output.rs @@ -1,23 +1,25 @@ //! IDEA-style progress and query folding; ordinary command output remains continuous text. -use super::types::{OutputFragment, Record}; +use super::types::{Display, OutputFragment, Record}; use regex::Regex; use std::sync::OnceLock; -pub(super) fn project(record: &Record) -> Vec { +/// Output of at most this many lines stays visible: opening a fold would cost more than +/// reading the lines it hides. +const VISIBLE_LINES: usize = 10; + +/// Folds nothing of a command that `deletes`, so every line of a deletion stays in sight. +pub(super) fn project(record: &Record, display: &Display, deletes: bool) -> Vec { + let folds = !deletes && !record.failed(); // A query's output answers the workflow, not the user: like IDEA's silent handlers it - // stays out of sight, folded whole, unless the query failed or wrote a single line. - if record.query && record.lines.len() > 1 && !record.failed() { - return vec![OutputFragment { - id: "output-0".into(), - start: 0, - end: record.lines.len(), - kind: "query".into(), - count: record.lines.len(), - added: 0, - updated: 0, - deleted: 0, - matches: 0, - }]; + // stays out of sight, folded whole, once it is longer than a glance, or at any length + // when the console's display choices ask. + let visible = if display.fold_short_queries { + 0 + } else { + VISIBLE_LINES + }; + if folds && record.query && record.lines.len() > visible { + return vec![fragment(0, record.lines.len(), "query")]; } let mut result = Vec::new(); let mut start = 0; @@ -29,23 +31,30 @@ pub(super) fn project(record: &Record) -> Vec { } } // A failed command keeps its progress and diagnostics expanded for inspection. - let folded = end > start + 1 && !record.failed(); - result.push(OutputFragment { - id: format!("output-{start}"), - start, - end, - kind: if folded { "progress" } else { "text" }.into(), - count: end - start, - added: 0, - updated: 0, - deleted: 0, - matches: 0, - }); + if folds && end - start > VISIBLE_LINES { + result.push(fragment(start, end, "progress")); + } else { + result.extend((start..end).map(|line| fragment(line, line + 1, "text"))); + } start = end; } result } +fn fragment(start: usize, end: usize, kind: &str) -> OutputFragment { + OutputFragment { + id: format!("output-{start}"), + start, + end, + kind: kind.into(), + count: end - start, + added: 0, + updated: 0, + deleted: 0, + matches: 0, + } +} + /// Matches IDEA's GitImplBase progress grammar, including remote-side phases. fn looks_like_progress(line: &str) -> bool { static PERCENT: OnceLock = OnceLock::new(); diff --git a/rust/crates/git/src/console/tests.rs b/rust/crates/git/src/console/tests.rs index c515d3d4..3375dfc0 100644 --- a/rust/crates/git/src/console/tests.rs +++ b/rust/crates/git/src/console/tests.rs @@ -202,7 +202,7 @@ fn expected_nonzero_queries_are_distinct_from_real_failures_and_limits_are_expli } #[test] -fn query_output_folds_whole_unless_the_query_failed_or_wrote_one_line() { +fn query_output_folds_whole_once_longer_than_ten_lines_unless_the_query_failed() { let make = |count: usize, query: bool, state: &str, exit: Option| -> Request { serde_json::from_value(json!({"search":"line 7", "records":[{ "id":"log", "root":"/repo", "arguments":["log","--max-count=50"], "state":state, @@ -230,8 +230,52 @@ fn query_output_folds_whole_unless_the_query_failed_or_wrote_one_line() { let failed = present(make(40, true, "completed", Some(128))).unwrap(); assert!(failed.entries[0].failed); assert!(failed.entries[0].output.iter().all(|f| f.kind == "text")); - let single = present(make(1, true, "completed", Some(0))).unwrap(); - assert_eq!(single.entries[0].output[0].kind, "text"); + // Ten lines are read at a glance; the eleventh makes the output worth a fold. + let short = present(make(10, true, "completed", Some(0))).unwrap(); + assert_eq!(short.entries[0].output.len(), 10); + assert!(short.entries[0].output.iter().all(|f| f.kind == "text")); + let long = present(make(11, true, "completed", Some(0))).unwrap(); + assert_eq!(long.entries[0].output[0].kind, "query"); + let mut asked = make(1, true, "completed", Some(0)); + asked.display.fold_short_queries = true; + assert_eq!(present(asked).unwrap().entries[0].output[0].kind, "query"); let visible = present(make(40, false, "completed", Some(0))).unwrap(); assert!(visible.entries[0].output.iter().all(|f| f.kind == "text")); } + +#[test] +fn deletions_keep_their_configuration_progress_and_queries_open() { + let make = |arguments: Value, lines: Vec, query: bool| -> Request { + serde_json::from_value(json!({"display":{"foldShortQueries":true}, "records":[{ + "id":"delete", "root":"/repo", "arguments":arguments, "state":"completed", + "exitCode":0, "query":query, "temporaryConfig":[["credential.helper",""]], + "lines":lines.iter().map(|text| json!({"stream":"stderr","text":text})).collect::>() + }]})) + .unwrap() + }; + let progress = (0..20) + .map(|i| format!("Receiving objects: {}% ({i}/20)", i * 5)) + .collect::>(); + let fetch = present(make(json!(["fetch", "origin"]), progress.clone(), false)).unwrap(); + assert_eq!(fetch.entries[0].output[0].kind, "progress"); + assert_eq!(fetch.entries[0].command[0].kind, "configuration"); + let prune = present(make(json!(["fetch", "origin", "--prune"]), progress, false)).unwrap(); + assert!(prune.entries[0].output.iter().all(|f| f.kind == "text")); + assert!(prune.entries[0].command.iter().all(|f| f.kind == "text")); + let listed = (0..20) + .map(|i| format!("Would remove build/{i}.o")) + .collect::>(); + let clean = present(make(json!(["clean", "-n", "-d"]), listed, true)).unwrap(); + assert_eq!(clean.entries[0].output.len(), 20); + assert!(clean.entries[0].output.iter().all(|f| f.kind == "text")); + let text = clean.entries[0] + .command + .iter() + .map(|f| f.text.clone()) + .collect::>() + .join(" "); + assert!( + text.starts_with("-c credential.helper= clean -n -d"), + "{text}" + ); +} diff --git a/rust/crates/git/src/console/types.rs b/rust/crates/git/src/console/types.rs index 0f15042f..cb7daa0b 100644 --- a/rust/crates/git/src/console/types.rs +++ b/rust/crates/git/src/console/types.rs @@ -11,6 +11,48 @@ pub struct Line { pub text: String, } +/// What an internal read-only query read, which decides whether a console records it. +/// `gitExecution.consoleQueries` lists the categories to record; none is recorded by default, +/// as IDEA's console leaves every read-only handler silent. +#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +pub enum QueryCategory { + /// Reference reads that follow a repository change without a user action. + References, + /// Reads that reload views after an operation the user ran. + Reload, + /// Diffs read again because a file they show was saved. + DiffRefresh, + /// File, commit, comparison and stash diffs the user opened. + Diff, + /// History, references and commit details the log shows. + Log, + /// The per-commit file lists a log path filter reads. + LogPathFilter, + /// Annotation and line history. + Annotate, + /// Lists and panels: worktrees, stashes, remotes, pull requests and settings. + Panels, + /// Previews, preflights, plans and the queries of operations themselves. + Checks, +} + +/// Display choices of a native console's settings. Every default is IDEA's console. +#[derive(Debug, Default, Deserialize)] +#[serde(rename_all = "camelCase", default, deny_unknown_fields)] +pub struct Display { + /// Fold a successful query's output at any length, so a query shows its command alone. + /// Unset, output of at most ten lines stays visible. A deletion is never folded. + pub fold_short_queries: bool, + /// Show the `completedWithoutOutput` notice; IDEA prints nothing when a command finishes. + pub show_completed_without_output: bool, + /// Omit Lithe's temporary configuration instead of folding it. `-c` arguments the + /// operation itself passed stay folded in place. + pub hide_temporary_config: bool, + /// Leave every entry's repository label empty and out of search. + pub hide_repository: bool, +} + /// Bounded native history; the presentation command performs no Git or filesystem work. #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -21,6 +63,8 @@ pub struct Request { /// Additional workspace roots disambiguate labels even before those repositories have output. #[serde(default)] pub repository_roots: Vec, + #[serde(default)] + pub(crate) display: Display, } /// Complete retained execution data; presentation never rewrites this input. @@ -47,7 +91,7 @@ pub struct Record { #[serde(default)] pub truncated: bool, /// The `query` of the record's `started` event: an internal query the workflow reported - /// only because the request asked for queries. Its output is folded unless it failed. + /// only because the request recorded its category. Its output is folded unless it failed. #[serde(default)] pub query: bool, } diff --git a/rust/crates/git/src/execution_events.rs b/rust/crates/git/src/execution_events.rs index 76ffc900..243afb6a 100644 --- a/rust/crates/git/src/execution_events.rs +++ b/rust/crates/git/src/execution_events.rs @@ -6,11 +6,12 @@ //! `lithe_request_context::events`. Native process ownership belongs to the //! `lithe-git-host` adapter. -use lithe_protocol::CoreError; +use lithe_protocol::{CoreError, ErrorCode}; use lithe_request_context::events::{deliver, EventSink}; pub(crate) use lithe_request_context::events::{emit, has_sink, redact}; use serde::Serialize; use std::cell::Cell; +use std::sync::{Arc, Mutex, PoisonError}; use std::time::Instant; const MAX_LINE_BYTES: usize = 16 * 1024; @@ -44,9 +45,13 @@ enum Kind<'a> { /// Native presentation folds global options without rewriting actual argv. display_arguments: Vec, global_arguments: Vec, - /// An internal query reported through `reportQueries`, as opposed to a command the - /// workflow runs visibly; consoles fold a query's output by default. + /// An internal query reported because the console records its category, as opposed + /// to a command the workflow runs visibly; consoles fold a query's output by default. query: bool, + /// The category of a query, so a console can drop the queries of a category it stops + /// recording; absent for a visible command and a query of no category. + #[serde(skip_serializing_if = "Option::is_none")] + query_category: Option, }, Output { invocation_id: u64, @@ -83,20 +88,44 @@ pub(super) struct Invocation { /// stays visible while stdout is replaced with one explicit redaction marker. redact_configuration: Cell, configuration_marker_sent: bool, - /// The child is an internal query reported only because the request asked for queries. + /// The child is an internal query reported only because the console records its category. query: bool, + /// The events of a query the console does not record, sent only if the query fails. + held: Option, +} +/// A query outside the recorded categories reports only a failure. Its events wait here, and +/// only on a real failure do they reach the request's consumer, before its `finished` event. +/// Stdout is not kept: Git writes a failure's diagnostics to stderr, and a successful query +/// then costs no serialized line of its output. +struct Held { + sink: EventSink, + events: Arc>>, + transfer: Cell, } impl Invocation { /// The invocation that reports a child: visible commands always report, and internal - /// queries only when the request set `reportQueries` and is not a background refresh. + /// queries when the console records the request's query category. Any other query of a + /// request that is not `background` reports only a failure. pub(super) fn reported(visible: bool) -> Option { - use super::{console::Source, execution_policy}; - let query = || { - execution_policy::current().report_queries - && execution_policy::source() != Source::Background - }; - let mut invocation = (visible || query()).then(Self::current).flatten()?; + let recorded = visible || super::execution_policy::reports_queries(); + let held = !recorded && super::execution_policy::reports_query_failures(); + let mut invocation = (recorded || held).then(Self::current).flatten()?; invocation.query = !visible; + if held { + let events = Arc::new(Mutex::new(Vec::new())); + let buffer = events.clone(); + let sink: EventSink = Arc::new(move |event: &str| { + buffer + .lock() + .unwrap_or_else(PoisonError::into_inner) + .push(event.to_string()) + }); + invocation.held = Some(Held { + sink: std::mem::replace(&mut invocation.sink, sink), + events, + transfer: Cell::new(false), + }); + } Some(invocation) } /// Whether an internal query's nonzero exit answered its question, such as a missing @@ -122,6 +151,7 @@ impl Invocation { redact_configuration: Cell::new(false), configuration_marker_sent: false, query: false, + held: None, }) } pub(super) fn started(&self, root: &str, arguments: &[String]) { @@ -168,7 +198,10 @@ impl Invocation { "fetch" | "push" | "pull" | "clone" ) }); - lithe_request_context::events::invocation_started(self.id, transfer); + match &self.held { + Some(held) => held.transfer.set(transfer), + None => lithe_request_context::events::invocation_started(self.id, transfer), + } let arguments = arguments .iter() .map(|argument| redact(argument)) @@ -195,6 +228,10 @@ impl Invocation { working_directory: root, arguments: &arguments, query: self.query, + query_category: self + .query + .then(super::execution_policy::query_category) + .flatten(), }, ); } @@ -207,6 +244,9 @@ impl Invocation { } } pub(super) fn output(&mut self, stream: lithe_git_host::Stream, bytes: &[u8]) { + if self.held.is_some() && matches!(stream, lithe_git_host::Stream::Stdout) { + return; + } if self.redact_configuration.get() && matches!(stream, lithe_git_host::Stream::Stdout) { if !bytes.is_empty() && !self.configuration_marker_sent { self.configuration_marker_sent = true; @@ -276,6 +316,20 @@ impl Invocation { error: Option<&CoreError>, expected_exit: bool, ) { + let failed = error.is_some() || !(exit_code == Some(0) || expected_exit); + if let Some(held) = self.held.take() { + // A cancelled query was superseded; like a success, it has nothing to report. + if !failed || error.is_some_and(|error| matches!(error.code, ErrorCode::Cancelled)) { + return; + } + self.sink = held.sink; + lithe_request_context::events::invocation_started(self.id, held.transfer.get()); + let events = + std::mem::take(&mut *held.events.lock().unwrap_or_else(PoisonError::into_inner)); + for event in events { + deliver(&self.sink, &event); + } + } if self.omitted { self.stdout = LineDecoder::default(); self.stderr = LineDecoder::default(); @@ -310,7 +364,6 @@ impl Invocation { message: redact(&error.message), details: error.details.as_ref().map(|value| redact(value)), }); - let failed = error.is_some() || !(exit_code == Some(0) || expected_exit); lithe_request_context::events::invocation_finished(self.id, failed); send( &self.sink, @@ -570,9 +623,10 @@ mod tests { #[test] fn reported_queries_are_marked_apart_from_visible_commands() { let options = crate::execution_policy::GitExecutionOptions { - report_queries: true, + console_queries: vec![crate::console::QueryCategory::Log], ..Default::default() - }; + } + .for_command("git.history"); let _policy = crate::execution_policy::Scope::begin(Some(options)).unwrap(); let events = capture_request(|| { request_started(Some("marked")); @@ -587,17 +641,90 @@ mod tests { let marks: Vec<_> = events .iter() .filter(|event| event["type"] == "started") - .map(|event| (event["arguments"][0].clone(), event["query"].clone())) + .map(|event| { + ( + event["arguments"][0].clone(), + event["query"].clone(), + event.get("queryCategory").cloned(), + ) + }) .collect(); assert_eq!( marks, [ - (serde_json::json!("log"), serde_json::json!(true)), - (serde_json::json!("commit"), serde_json::json!(false)) + ( + serde_json::json!("log"), + serde_json::json!(true), + Some(serde_json::json!("log")) + ), + (serde_json::json!("commit"), serde_json::json!(false), None) ] ); } + /// A query outside the recorded categories stays silent until it really fails; then the + /// console gets its command, its stderr and its exit, and no separate failure record. + #[test] + fn unrecorded_queries_report_only_a_real_failure() { + let run = |source: crate::console::Source| { + let options = crate::execution_policy::GitExecutionOptions { + source, + ..Default::default() + } + .for_command("git.history"); + let _policy = crate::execution_policy::Scope::begin(Some(options)).unwrap(); + let cancelled = CoreError::new(ErrorCode::Cancelled, "Operation was cancelled"); + let ends: [(&[&str], Option, Option<&CoreError>); 3] = [ + (&["log"], Some(0), None), + (&["log"], None, Some(&cancelled)), + (&["rev-parse", "HEAD"], Some(128), None), + ]; + capture_request(|| { + request_started(Some("silent")); + for (arguments, exit_code, error) in ends { + // A background request reports no unrecorded query at all. + let Some(mut query) = Invocation::reported(false) else { + continue; + }; + let arguments = arguments.iter().map(|a| a.to_string()).collect::>(); + query.started("/workspace", &arguments); + query.output(lithe_git_host::Stream::Stdout, b"partial\n"); + query.output(lithe_git_host::Stream::Stderr, b"fatal: bad object\n"); + query.finished(exit_code, error); + } + request_finished(r#"{"ok":false,"error":{"code":"process_failed","message":"x"}}"#); + }) + }; + let events = run(crate::console::Source::User); + let kinds = events + .iter() + .map(|event| event["type"].as_str().unwrap()) + .collect::>(); + assert_eq!( + kinds, + [ + "requestStarted", + "started", + "output", + "finished", + "requestFinished" + ] + ); + assert_eq!( + events[1]["arguments"], + serde_json::json!(["rev-parse", "HEAD"]) + ); + assert_eq!(events[1]["query"], true); + assert_eq!(events[2]["stream"], "stderr"); + assert_eq!(events[2]["text"], "fatal: bad object"); + assert_eq!(events[3]["exitCode"], 128); + assert_eq!(events[4]["failureRecord"], false); + assert_eq!(events[4]["unconfirmedInvocations"], serde_json::json!([])); + let background = run(crate::console::Source::Background); + assert_eq!(background.len(), 2, "{background:?}"); + assert_eq!(background[1]["failureRecord"], true); + } + #[test] fn request_finished_names_unconfirmed_records_and_early_failures() { let events = capture_request(|| { diff --git a/rust/crates/git/src/execution_policy.rs b/rust/crates/git/src/execution_policy.rs index fcc1d07d..3cf6cb01 100644 --- a/rust/crates/git/src/execution_policy.rs +++ b/rust/crates/git/src/execution_policy.rs @@ -1,5 +1,6 @@ //! Request-scoped execution choices and deterministic temporary configuration. +use super::console::QueryCategory; use super::fetch::GitFetchOptions; use lithe_protocol::{CoreError, ErrorCode}; use serde::{Deserialize, Serialize}; @@ -21,11 +22,18 @@ pub struct GitExecutionOptions { pub detailed_fetch: bool, /// Explicit operation provenance; unknown requests must never be deduplicated. pub source: super::console::Source, - /// Internal read-only queries emit execution events like visible commands, so a console - /// records what the workbench read, except under `background` provenance: automatic - /// refreshes and watchers run too often to record. Authentication and interactivity stay - /// with visible commands; a query never prompts. - pub report_queries: bool, + /// The query categories a console records: their internal read-only queries emit + /// execution events like visible commands. Empty by default, as IDEA leaves every + /// read-only handler silent. Authentication and interactivity stay with visible commands; + /// a query never prompts. + pub console_queries: Vec, + /// What the request's queries read, named by the host for reads the request command + /// alone does not tell apart, such as a reload after an operation. + pub query_category: Option, + /// The request command's own category, which the dispatcher installs with + /// [`GitExecutionOptions::for_command`]; it is never read from the request. + #[serde(skip)] + pub command_category: Option, } impl Default for GitExecutionOptions { fn default() -> Self { @@ -36,10 +44,19 @@ impl Default for GitExecutionOptions { fetch_defaults: GitFetchOptions::default(), detailed_fetch: false, source: super::console::Source::Unknown, - report_queries: false, + console_queries: Vec::new(), + query_category: None, + command_category: None, } } } +impl GitExecutionOptions { + /// These options for a request of `command`, whose queries default to its category. + pub fn for_command(mut self, command: &str) -> Self { + self.command_category = super::console::category::of_command(command); + self + } +} thread_local! { static OPTIONS: RefCell = RefCell::new(GitExecutionOptions::default()); } @@ -83,6 +100,32 @@ pub(super) fn source() -> super::console::Source { } } +/// The category of the running request's internal queries: the one the host named, or else +/// the request command's. A `background` request without a named category is an automatic +/// refresh or watcher, whose queries belong to no category. +pub(super) fn query_category() -> Option { + let options = current(); + options.query_category.or_else(|| { + (source() != super::console::Source::Background) + .then_some(options.command_category) + .flatten() + }) +} + +/// Whether the running request's internal queries are recorded: their category is one the +/// console records. Queries of no category, those of an automatic refresh or watcher, run too +/// often to record. +pub(super) fn reports_queries() -> bool { + query_category().is_some_and(|category| current().console_queries.contains(&category)) +} + +/// Whether the running request's unrecorded queries still report a failure: a request that +/// is not `background`, as every such query did before the console chose categories. +/// Background refreshes and watchers stay silent even when a read fails. +pub(super) fn reports_query_failures() -> bool { + source() != super::console::Source::Background +} + /// Environment configuration and scope provenance require Git 2.31 or newer. pub(super) fn validate_version(version: &str) -> Result<(), CoreError> { let supported = version @@ -251,4 +294,50 @@ mod tests { })) .is_err()); } + + /// The shared cases fix each command's category and which queries a console records. + #[test] + fn console_queries_follow_the_named_or_command_category() { + let fixture: serde_json::Value = serde_json::from_str(include_str!( + "../../../fixtures/git/console-queries-v1.json" + )) + .unwrap(); + // Hosts read the whole list from the fixture. The match fails to compile when a + // category is added, so the list cannot fall behind the enum. + use super::super::console::QueryCategory::*; + let categories: Vec = + serde_json::from_value(fixture["queryCategories"].clone()).unwrap(); + let positions = categories.iter().map(|category| match category { + References => 0, + Reload => 1, + DiffRefresh => 2, + Diff => 3, + Log => 4, + LogPathFilter => 5, + Annotate => 6, + Panels => 7, + Checks => 8, + }); + assert!(positions.eq(0..9), "{categories:?}"); + for (command, category) in fixture["categories"].as_object().unwrap() { + assert_eq!( + serde_json::json!(super::super::console::category::of_command(command)), + *category, + "{command}" + ); + } + for case in fixture["cases"].as_array().unwrap() { + let options: GitExecutionOptions = + serde_json::from_value(case["gitExecution"].clone()).unwrap(); + let _scope = + Scope::begin(Some(options.for_command(case["command"].as_str().unwrap()))).unwrap(); + assert_eq!( + reports_queries(), + case["reported"].as_bool().unwrap(), + "{}", + case["name"] + ); + } + assert!(!reports_queries()); + } } diff --git a/rust/crates/git/src/process.rs b/rust/crates/git/src/process.rs index e16842e2..1c28a334 100644 --- a/rust/crates/git/src/process.rs +++ b/rust/crates/git/src/process.rs @@ -147,7 +147,7 @@ pub fn execute_git( } /// Runs one internal read-only Git query with optional locks disabled. It never -/// prompts, and reaches the console only when the request sets `reportQueries`. +/// prompts, and reaches the console only when the request records its query category. pub fn execute_git_readonly( root: &str, arguments: &[String], diff --git a/rust/fixtures/git/console-presentation-v1.json b/rust/fixtures/git/console-presentation-v1.json index 0e16c984..164ecb25 100644 --- a/rust/fixtures/git/console-presentation-v1.json +++ b/rust/fixtures/git/console-presentation-v1.json @@ -100,7 +100,7 @@ "id": "one", "output": [], "repositoryLabel": "/workspace/repo", - "notice": "completedWithoutOutput" + "notice": null } ], "groups": [ @@ -2234,7 +2234,7 @@ "id": "one", "output": [], "repositoryLabel": "/workspace/repo", - "notice": "completedWithoutOutput" + "notice": null } ], "groups": [ @@ -2340,7 +2340,7 @@ "id": "one", "output": [], "repositoryLabel": "/workspace/repo", - "notice": "completedWithoutOutput" + "notice": null } ], "groups": [ @@ -3220,7 +3220,7 @@ "id": "0", "output": [], "repositoryLabel": "/workspace/repo", - "notice": "completedWithoutOutput" + "notice": null }, { "command": [ @@ -3253,7 +3253,7 @@ "id": "1", "output": [], "repositoryLabel": "/workspace/repo", - "notice": "completedWithoutOutput" + "notice": null } ], "groups": [ @@ -3356,7 +3356,7 @@ "id": "a", "output": [], "repositoryLabel": "/workspace/a/repo", - "notice": "completedWithoutOutput" + "notice": null }, { "command": [ @@ -3381,7 +3381,7 @@ "id": "b", "output": [], "repositoryLabel": "/workspace/b/repo", - "notice": "completedWithoutOutput" + "notice": null } ], "groups": [ @@ -3724,7 +3724,7 @@ "id": "before", "output": [], "repositoryLabel": "/workspace/one/project", - "notice": "completedWithoutOutput" + "notice": null }, { "command": [ @@ -3741,7 +3741,7 @@ "id": "after", "output": [], "repositoryLabel": "/workspace/one/project", - "notice": "completedWithoutOutput" + "notice": null } ], "groups": [ @@ -3776,36 +3776,65 @@ } }, { - "name": "IDEA progress folding uses a contiguous block and leaves diagnostics visible", + "name": "IDEA progress folding uses a contiguous block longer than ten lines and leaves diagnostics visible", "input": { - "search": "Counting", "records": [ { "id": "progress", "root": "/workspace/repository", "arguments": [ "fetch", - "origin", - "--prune" + "origin" ], - "state": "completed", - "exitCode": 0, + "temporaryConfig": [], "lines": [ { "stream": "stderr", - "text": "remote: Enumerating objects: 8, done." + "text": "remote: Enumerating objects: 120, done." + }, + { + "stream": "stderr", + "text": "remote: Counting objects: 100% (120/120), done." + }, + { + "stream": "stderr", + "text": "remote: Compressing objects: 100% (60/60), done." + }, + { + "stream": "stderr", + "text": "Receiving objects: 10% (12/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 20% (24/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 30% (36/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 40% (48/120)" }, { "stream": "stderr", - "text": "remote: Counting objects: 100% (8/8), done." + "text": "Receiving objects: 50% (60/120)" }, { "stream": "stderr", - "text": "remote: Compressing objects: 100% (4/4), done." + "text": "Receiving objects: 60% (72/120)" }, { "stream": "stderr", - "text": "remote: Total 8 (delta 3), reused 8 (delta 3)" + "text": "Receiving objects: 70% (84/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 80% (96/120)" + }, + { + "stream": "stderr", + "text": "Resolving deltas: 100% (40/40), done." }, { "stream": "stderr", @@ -3815,15 +3844,18 @@ "stream": "stderr", "text": " abc1234..def5678 main -> origin/main" } - ] + ], + "state": "completed", + "exitCode": 0 } - ] + ], + "search": "Counting" }, "expected": { "folds": [ [ 0, - 3, + 12, "progress" ] ], @@ -3832,98 +3864,79 @@ "presentation": { "entries": [ { + "id": "progress", + "repositoryLabel": "/workspace/repository", "command": [ { - "count": 1, "id": "argument-0", "kind": "text", - "matches": 0, + "text": "fetch", "preview": "", - "text": "fetch" + "count": 1, + "matches": 0 }, { - "count": 1, "id": "argument-1", "kind": "text", - "matches": 0, + "text": "origin", "preview": "", - "text": "origin" - }, - { "count": 1, - "id": "argument-2", - "kind": "text", - "matches": 0, - "preview": "", - "text": "--prune" + "matches": 0 } ], - "failed": false, - "id": "progress", "output": [ { - "added": 0, - "count": 3, - "deleted": 0, - "end": 3, "id": "output-0", - "kind": "progress", - "matches": 1, "start": 0, - "updated": 0 - }, - { + "end": 12, + "kind": "progress", + "count": 12, "added": 0, - "count": 1, + "updated": 0, "deleted": 0, - "end": 4, - "id": "output-3", - "kind": "text", - "matches": 0, - "start": 3, - "updated": 0 + "matches": 1 }, { - "added": 0, + "id": "output-12", + "start": 12, + "end": 13, + "kind": "text", "count": 1, + "added": 0, + "updated": 0, "deleted": 0, - "end": 5, - "id": "output-4", - "kind": "text", - "matches": 0, - "start": 4, - "updated": 0 + "matches": 0 }, { - "added": 0, + "id": "output-13", + "start": 13, + "end": 14, + "kind": "text", "count": 1, + "added": 0, + "updated": 0, "deleted": 0, - "end": 6, - "id": "output-5", - "kind": "text", - "matches": 0, - "start": 5, - "updated": 0 + "matches": 0 } ], - "repositoryLabel": "/workspace/repository", + "failed": false, "notice": null } ], "groups": [ { "id": "progress", - "matches": 1, "recordIds": [ "progress" - ] + ], + "matches": 1 } ], "matches": [ { + "recordId": "progress", "fragmentId": "output-0", - "lineIndex": 1, - "recordId": "progress" + "lineIndex": 1 } ], "totalMatches": 1 @@ -4009,7 +4022,10 @@ "exitCode": 0 } ], - "search": "" + "search": "", + "display": { + "showCompletedWithoutOutput": true + } }, "expected": { "notice": "completedWithoutOutput" @@ -4144,7 +4160,10 @@ } } ], - "search": "" + "search": "", + "display": { + "showCompletedWithoutOutput": true + } }, "expected": { "notice": "completedWithoutOutput" @@ -4213,7 +4232,10 @@ } } ], - "search": "" + "search": "", + "display": { + "showCompletedWithoutOutput": true + } }, "expected": { "notice": "completedWithoutOutput" @@ -4450,6 +4472,1966 @@ "matches": [], "totalMatches": 0 } + }, + { + "name": "a command without output shows no notice by default", + "input": { + "records": [ + { + "id": "quiet", + "root": "/workspace/repository", + "arguments": [ + "checkout", + "main" + ], + "temporaryConfig": [], + "lines": [], + "state": "completed", + "exitCode": 0 + } + ], + "search": "" + }, + "expected": { + "notice": null + }, + "presentation": { + "entries": [ + { + "id": "quiet", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "checkout", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "main", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "quiet", + "recordIds": [ + "quiet" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a query of ten lines stays visible by default", + "input": { + "records": [ + { + "id": "refs", + "root": "/workspace/repository", + "arguments": [ + "for-each-ref", + "--format=%(refname) %(objectname)" + ], + "temporaryConfig": [], + "lines": [ + { + "stream": "stdout", + "text": "refs/heads/topic-0 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-1 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-2 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-3 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-4 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-5 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-6 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-7 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-8 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-9 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + } + ], + "state": "completed", + "exitCode": 0, + "query": true + } + ], + "search": "" + }, + "expected": { + "folds": [] + }, + "presentation": { + "entries": [ + { + "id": "refs", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "for-each-ref", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "'--format=%(refname) %(objectname)'", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [ + { + "id": "output-0", + "start": 0, + "end": 1, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-1", + "start": 1, + "end": 2, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-2", + "start": 2, + "end": 3, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-3", + "start": 3, + "end": 4, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-4", + "start": 4, + "end": 5, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-5", + "start": 5, + "end": 6, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-6", + "start": 6, + "end": 7, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-7", + "start": 7, + "end": 8, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-8", + "start": 8, + "end": 9, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-9", + "start": 9, + "end": 10, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + } + ], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "refs", + "recordIds": [ + "refs" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a short query folds when the display asks", + "input": { + "records": [ + { + "id": "rev", + "root": "/workspace/repository", + "arguments": [ + "rev-parse", + "HEAD" + ], + "temporaryConfig": [], + "lines": [ + { + "stream": "stdout", + "text": "4b825dc642cb6eb9a060e54bf8d69288fbee4904" + } + ], + "state": "completed", + "exitCode": 0, + "query": true + } + ], + "search": "", + "display": { + "foldShortQueries": true + } + }, + "expected": { + "folds": [ + [ + 0, + 1, + "query" + ] + ] + }, + "presentation": { + "entries": [ + { + "id": "rev", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "rev-parse", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "HEAD", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [ + { + "id": "output-0", + "start": 0, + "end": 1, + "kind": "query", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + } + ], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "rev", + "recordIds": [ + "rev" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "hidden temporary configuration keeps the operation's own configuration", + "input": { + "records": [ + { + "id": "hooks", + "root": "/workspace/repository", + "arguments": [ + "-c", + "core.hooksPath=/hooks", + "commit", + "-m", + "x" + ], + "temporaryConfig": [ + [ + "color.ui", + "false" + ], + [ + "core.quotepath", + "false" + ] + ], + "lines": [], + "state": "completed", + "exitCode": 0 + } + ], + "search": "", + "display": { + "hideTemporaryConfig": true + } + }, + "expected": { + "commandFoldKinds": [ + "configuration" + ], + "visibleCommandContains": [ + "commit -m x" + ] + }, + "presentation": { + "entries": [ + { + "id": "hooks", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "configuration-0", + "kind": "configuration", + "text": "-c core.hooksPath=/hooks", + "preview": "-c …", + "count": 1, + "matches": 0 + }, + { + "id": "argument-2", + "kind": "text", + "text": "commit", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-3", + "kind": "text", + "text": "-m", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-4", + "kind": "text", + "text": "x", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "hooks", + "recordIds": [ + "hooks" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a hidden repository label is empty and out of search", + "input": { + "records": [ + { + "id": "hidden", + "root": "/workspace/needle", + "arguments": [ + "status" + ], + "temporaryConfig": [], + "lines": [], + "state": "completed", + "exitCode": 0 + } + ], + "search": "needle", + "display": { + "hideRepository": true + } + }, + "expected": { + "labels": [ + "" + ], + "matches": 0 + }, + "presentation": { + "entries": [ + { + "id": "hidden", + "repositoryLabel": "", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "status", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "hidden", + "recordIds": [ + "hidden" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a progress block of ten lines stays visible", + "input": { + "records": [ + { + "id": "short-progress", + "root": "/workspace/repository", + "arguments": [ + "fetch", + "origin" + ], + "temporaryConfig": [], + "lines": [ + { + "stream": "stderr", + "text": "remote: Enumerating objects: 120, done." + }, + { + "stream": "stderr", + "text": "remote: Counting objects: 100% (120/120), done." + }, + { + "stream": "stderr", + "text": "remote: Compressing objects: 100% (60/60), done." + }, + { + "stream": "stderr", + "text": "Receiving objects: 10% (12/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 20% (24/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 30% (36/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 40% (48/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 50% (60/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 60% (72/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 70% (84/120)" + }, + { + "stream": "stderr", + "text": "From https://example.invalid/repository" + } + ], + "state": "completed", + "exitCode": 0 + } + ], + "search": "" + }, + "expected": { + "folds": [] + }, + "presentation": { + "entries": [ + { + "id": "short-progress", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "fetch", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "origin", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [ + { + "id": "output-0", + "start": 0, + "end": 1, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-1", + "start": 1, + "end": 2, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-2", + "start": 2, + "end": 3, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-3", + "start": 3, + "end": 4, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-4", + "start": 4, + "end": 5, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-5", + "start": 5, + "end": 6, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-6", + "start": 6, + "end": 7, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-7", + "start": 7, + "end": 8, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-8", + "start": 8, + "end": 9, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-9", + "start": 9, + "end": 10, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-10", + "start": 10, + "end": 11, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + } + ], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "short-progress", + "recordIds": [ + "short-progress" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a query longer than ten lines folds whole", + "input": { + "records": [ + { + "id": "refs", + "root": "/workspace/repository", + "arguments": [ + "for-each-ref", + "--format=%(refname) %(objectname)" + ], + "temporaryConfig": [], + "lines": [ + { + "stream": "stdout", + "text": "refs/heads/topic-0 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-1 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-2 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-3 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-4 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-5 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-6 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-7 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-8 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-9 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + }, + { + "stream": "stdout", + "text": "refs/heads/topic-10 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + } + ], + "state": "completed", + "exitCode": 0, + "query": true + } + ], + "search": "" + }, + "expected": { + "folds": [ + [ + 0, + 11, + "query" + ] + ] + }, + "presentation": { + "entries": [ + { + "id": "refs", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "for-each-ref", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "'--format=%(refname) %(objectname)'", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [ + { + "id": "output-0", + "start": 0, + "end": 11, + "kind": "query", + "count": 11, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + } + ], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "refs", + "recordIds": [ + "refs" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a pruning fetch keeps its configuration and progress open", + "input": { + "records": [ + { + "id": "prune", + "root": "/workspace/repository", + "arguments": [ + "fetch", + "--progress", + "--prune", + "origin" + ], + "temporaryConfig": [ + [ + "color.ui", + "false" + ] + ], + "lines": [ + { + "stream": "stderr", + "text": "remote: Enumerating objects: 120, done." + }, + { + "stream": "stderr", + "text": "remote: Counting objects: 100% (120/120), done." + }, + { + "stream": "stderr", + "text": "remote: Compressing objects: 100% (60/60), done." + }, + { + "stream": "stderr", + "text": "Receiving objects: 10% (12/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 20% (24/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 30% (36/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 40% (48/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 50% (60/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 60% (72/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 70% (84/120)" + }, + { + "stream": "stderr", + "text": "Receiving objects: 80% (96/120)" + }, + { + "stream": "stderr", + "text": "Resolving deltas: 100% (40/40), done." + }, + { + "stream": "stderr", + "text": "From https://example.invalid/repository" + }, + { + "stream": "stderr", + "text": " abc1234..def5678 main -> origin/main" + }, + { + "stream": "stderr", + "text": " - [deleted] (none) -> origin/topic" + } + ], + "state": "completed", + "exitCode": 0 + } + ], + "search": "" + }, + "expected": { + "folds": [], + "commandFoldKinds": [], + "visibleCommandContains": [ + "-c color.ui=false fetch --progress --prune" + ] + }, + "presentation": { + "entries": [ + { + "id": "prune", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "-c", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "color.ui=false", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-2", + "kind": "text", + "text": "fetch", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-3", + "kind": "text", + "text": "--progress", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-4", + "kind": "text", + "text": "--prune", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-5", + "kind": "text", + "text": "origin", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [ + { + "id": "output-0", + "start": 0, + "end": 1, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-1", + "start": 1, + "end": 2, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-2", + "start": 2, + "end": 3, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-3", + "start": 3, + "end": 4, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-4", + "start": 4, + "end": 5, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-5", + "start": 5, + "end": 6, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-6", + "start": 6, + "end": 7, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-7", + "start": 7, + "end": 8, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-8", + "start": 8, + "end": 9, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-9", + "start": 9, + "end": 10, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-10", + "start": 10, + "end": 11, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-11", + "start": 11, + "end": 12, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-12", + "start": 12, + "end": 13, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-13", + "start": 13, + "end": 14, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-14", + "start": 14, + "end": 15, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + } + ], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "prune", + "recordIds": [ + "prune" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "a deletion query is never folded", + "input": { + "records": [ + { + "id": "would", + "root": "/workspace/repository", + "arguments": [ + "clean", + "-n", + "-d" + ], + "temporaryConfig": [], + "lines": [ + { + "stream": "stdout", + "text": "Would remove build/0.o" + }, + { + "stream": "stdout", + "text": "Would remove build/1.o" + }, + { + "stream": "stdout", + "text": "Would remove build/2.o" + }, + { + "stream": "stdout", + "text": "Would remove build/3.o" + }, + { + "stream": "stdout", + "text": "Would remove build/4.o" + }, + { + "stream": "stdout", + "text": "Would remove build/5.o" + }, + { + "stream": "stdout", + "text": "Would remove build/6.o" + }, + { + "stream": "stdout", + "text": "Would remove build/7.o" + }, + { + "stream": "stdout", + "text": "Would remove build/8.o" + }, + { + "stream": "stdout", + "text": "Would remove build/9.o" + }, + { + "stream": "stdout", + "text": "Would remove build/10.o" + }, + { + "stream": "stdout", + "text": "Would remove build/11.o" + } + ], + "state": "completed", + "exitCode": 0, + "query": true + } + ], + "search": "", + "display": { + "foldShortQueries": true + } + }, + "expected": { + "folds": [] + }, + "presentation": { + "entries": [ + { + "id": "would", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "clean", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "-n", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-2", + "kind": "text", + "text": "-d", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [ + { + "id": "output-0", + "start": 0, + "end": 1, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-1", + "start": 1, + "end": 2, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-2", + "start": 2, + "end": 3, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-3", + "start": 3, + "end": 4, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-4", + "start": 4, + "end": 5, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-5", + "start": 5, + "end": 6, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-6", + "start": 6, + "end": 7, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-7", + "start": 7, + "end": 8, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-8", + "start": 8, + "end": 9, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-9", + "start": 9, + "end": 10, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-10", + "start": 10, + "end": 11, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + }, + { + "id": "output-11", + "start": 11, + "end": 12, + "kind": "text", + "count": 1, + "added": 0, + "updated": 0, + "deleted": 0, + "matches": 0 + } + ], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "would", + "recordIds": [ + "would" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + }, + { + "name": "deleting a branch shows the configuration it ran with", + "input": { + "records": [ + { + "id": "delete", + "root": "/workspace/repository", + "arguments": [ + "-c", + "core.hooksPath=/hooks", + "update-ref", + "-d", + "refs/heads/topic", + "4b825dc642cb6eb9a060e54bf8d69288fbee4904" + ], + "temporaryConfig": [ + [ + "color.ui", + "false" + ] + ], + "lines": [], + "state": "completed", + "exitCode": 0 + } + ], + "search": "" + }, + "expected": { + "commandFoldKinds": [], + "visibleCommandContains": [ + "-c color.ui=false -c core.hooksPath=/hooks update-ref -d refs/heads/topic" + ] + }, + "presentation": { + "entries": [ + { + "id": "delete", + "repositoryLabel": "/workspace/repository", + "command": [ + { + "id": "argument-0", + "kind": "text", + "text": "-c", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-1", + "kind": "text", + "text": "color.ui=false", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-2", + "kind": "text", + "text": "-c", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-3", + "kind": "text", + "text": "core.hooksPath=/hooks", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-4", + "kind": "text", + "text": "update-ref", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-5", + "kind": "text", + "text": "-d", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-6", + "kind": "text", + "text": "refs/heads/topic", + "preview": "", + "count": 1, + "matches": 0 + }, + { + "id": "argument-7", + "kind": "text", + "text": "4b825dc642cb6eb9a060e54bf8d69288fbee4904", + "preview": "", + "count": 1, + "matches": 0 + } + ], + "output": [], + "failed": false, + "notice": null + } + ], + "groups": [ + { + "id": "delete", + "recordIds": [ + "delete" + ], + "matches": 0 + } + ], + "matches": [], + "totalMatches": 0 + } + } + ], + "deletions": [ + { + "arguments": [ + "update-ref", + "-d", + "refs/heads/topic", + "4b825dc642cb6eb9a060e54bf8d69288fbee4904" + ], + "deletes": true + }, + { + "arguments": [ + "-c", + "color.ui=false", + "-C", + "/workspace/repository", + "branch", + "-d", + "topic" + ], + "deletes": true + }, + { + "arguments": [ + "branch", + "-D", + "topic" + ], + "deletes": true + }, + { + "arguments": [ + "branch", + "--delete", + "topic" + ], + "deletes": true + }, + { + "arguments": [ + "tag", + "-d", + "v1.0" + ], + "deletes": true + }, + { + "arguments": [ + "symbolic-ref", + "--delete", + "refs/remotes/origin/HEAD" + ], + "deletes": true + }, + { + "arguments": [ + "push", + "--delete", + "--", + "origin", + "refs/heads/topic" + ], + "deletes": true + }, + { + "arguments": [ + "push", + "origin", + ":refs/heads/topic" + ], + "deletes": true + }, + { + "arguments": [ + "push", + "--prune", + "origin", + "refs/heads/*:refs/heads/*" + ], + "deletes": true + }, + { + "arguments": [ + "fetch", + "--progress", + "--all", + "--prune" + ], + "deletes": true + }, + { + "arguments": [ + "fetch", + "-p", + "origin" + ], + "deletes": true + }, + { + "arguments": [ + "fetch", + "--prune-tags", + "origin" + ], + "deletes": true + }, + { + "arguments": [ + "pull", + "--prune" + ], + "deletes": true + }, + { + "arguments": [ + "remote", + "remove", + "upstream" + ], + "deletes": true + }, + { + "arguments": [ + "remote", + "rm", + "upstream" + ], + "deletes": true + }, + { + "arguments": [ + "remote", + "prune", + "origin" + ], + "deletes": true + }, + { + "arguments": [ + "remote", + "update", + "--prune" + ], + "deletes": true + }, + { + "arguments": [ + "config", + "--unset", + "remote.origin.pushurl" + ], + "deletes": true + }, + { + "arguments": [ + "config", + "--remove-section", + "remote.upstream" + ], + "deletes": true + }, + { + "arguments": [ + "config", + "unset", + "user.name" + ], + "deletes": true + }, + { + "arguments": [ + "rm", + "--cached", + "--force", + "--ignore-unmatch", + "--pathspec-from-file=-" + ], + "deletes": true + }, + { + "arguments": [ + "clean", + "-f", + "-d", + "--" + ], + "deletes": true + }, + { + "arguments": [ + "clean", + "-n", + "-d" + ], + "deletes": true + }, + { + "arguments": [ + "stash", + "drop", + "stash@{0}" + ], + "deletes": true + }, + { + "arguments": [ + "stash", + "clear" + ], + "deletes": true + }, + { + "arguments": [ + "stash", + "pop", + "stash@{0}" + ], + "deletes": true + }, + { + "arguments": [ + "worktree", + "remove", + "--force", + "/workspace/other" + ], + "deletes": true + }, + { + "arguments": [ + "worktree", + "prune", + "--verbose", + "--expire=now" + ], + "deletes": true + }, + { + "arguments": [ + "fetch", + "--progress", + "--no-prune" + ], + "deletes": false + }, + { + "arguments": [ + "fetch", + "origin" + ], + "deletes": false + }, + { + "arguments": [ + "branch", + "--list", + "topic" + ], + "deletes": false + }, + { + "arguments": [ + "tag", + "--list", + "--", + "-d" + ], + "deletes": false + }, + { + "arguments": [ + "update-ref", + "refs/heads/topic", + "4b825dc642cb6eb9a060e54bf8d69288fbee4904" + ], + "deletes": false + }, + { + "arguments": [ + "push", + "origin", + "main" + ], + "deletes": false + }, + { + "arguments": [ + "push", + "--force-with-lease", + "origin", + "+main:main" + ], + "deletes": false + }, + { + "arguments": [ + "remote", + "add", + "upstream", + "https://example.invalid/repository" + ], + "deletes": false + }, + { + "arguments": [ + "remote", + "update" + ], + "deletes": false + }, + { + "arguments": [ + "config", + "--get", + "user.name" + ], + "deletes": false + }, + { + "arguments": [ + "stash", + "list" + ], + "deletes": false + }, + { + "arguments": [ + "stash", + "push", + "--", + "dropped.txt" + ], + "deletes": false + }, + { + "arguments": [ + "worktree", + "list", + "--porcelain" + ], + "deletes": false + }, + { + "arguments": [ + "log", + "--", + "removed.txt" + ], + "deletes": false + }, + { + "arguments": [ + "status" + ], + "deletes": false + }, + { + "arguments": [], + "deletes": false } ] } diff --git a/rust/fixtures/git/console-queries-v1.json b/rust/fixtures/git/console-queries-v1.json new file mode 100644 index 00000000..5b99a7cb --- /dev/null +++ b/rust/fixtures/git/console-queries-v1.json @@ -0,0 +1,84 @@ +{ + "version": 1, + "queryCategories": [ + "references", + "reload", + "diffRefresh", + "diff", + "log", + "logPathFilter", + "annotate", + "panels", + "checks" + ], + "categories": { + "git.diff": "diff", + "git.comparison": "diff", + "git.history": "log", + "git.references": "log", + "git.commitFiles": "log", + "git.blame": "annotate", + "git.lineHistory": "annotate", + "git.worktrees": "panels", + "git.stashes": "panels", + "git.pullRequestContext": "panels", + "git.checkoutPreflight": "checks", + "git.write": "checks", + "git.status": "checks", + "project.search": null + }, + "cases": [ + { + "name": "IDEA defaults record no query", + "command": "git.history", + "gitExecution": {}, + "reported": false + }, + { + "name": "a recorded category reports the command's queries", + "command": "git.history", + "gitExecution": { "consoleQueries": ["log"] }, + "reported": true + }, + { + "name": "another category stays silent", + "command": "git.diff", + "gitExecution": { "consoleQueries": ["log"] }, + "reported": false + }, + { + "name": "unlisted Git commands are checks", + "command": "git.checkoutPreflight", + "gitExecution": { "consoleQueries": ["checks"] }, + "reported": true + }, + { + "name": "a background refresh without a named category stays silent", + "command": "git.status", + "gitExecution": { "consoleQueries": ["checks"], "source": "background" }, + "reported": false + }, + { + "name": "a named category replaces the command's", + "command": "git.history", + "gitExecution": { "consoleQueries": ["log"], "queryCategory": "reload" }, + "reported": false + }, + { + "name": "a named background category is recorded when the console records it", + "command": "git.references", + "gitExecution": { + "consoleQueries": ["references"], + "queryCategory": "references", + "source": "background" + }, + "reported": true + }, + { + "name": "commands outside Git have no category", + "command": "project.search", + "gitExecution": { "consoleQueries": ["checks"] }, + "reported": false + } + ] +}