Skip to content

diagnose: improve result reporting and output - #2425

Open
mjcheetham wants to merge 6 commits into
git-ecosystem:mainfrom
mjcheetham:diagnose-v2
Open

diagnose: improve result reporting and output#2425
mjcheetham wants to merge 6 commits into
git-ecosystem:mainfrom
mjcheetham:diagnose-v2

Conversation

@mjcheetham

Copy link
Copy Markdown
Contributor

Update git-credential-manager diagnose to report structured diagnostic outcomes instead of collapsing each diagnostic into a true/false result and an unstructured log.

  • Distinguish successful, warning, error, and skipped diagnostic outcomes.

  • Use Spectre.Console to show live diagnostic status, colour-coded results, and a consolidated summary with generated log file paths.

  • Add --strict so automated checks can treat warnings as a non-zero exit, while preserving the default behaviour of failing only on errors.

  • Collect exceptions and additional files through the diagnostic reporter so presentation, logging, and file copying are handled consistently.

  • Allow diagnostics to be registered explicitly, making the command infrastructure easier to test independently of the standard diagnostics.

  • Add coverage for command exit behaviour and structured networking reports.

This ultimately forms a better base for expanding our diagnostic tests.

Example Terminal Output

image image

@mjcheetham
mjcheetham requested a review from a team as a code owner August 28, 2026 15:19
Allow the creation of the diagnose command without the standard
diagnostics. This will enable us to add tests in the future that
exercise the diagnostic infrastructure without always adding the
standard diagnostics. The main application adds them when it creates the
command.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Diagnostics currently collapse each run into a Boolean and an unstructured
string log. That makes warnings indistinguishable from useful progress and
forces tests to assert against presentation text.

Introduce typed reports and derive success, warning, error, and skipped
outcomes from them. Migrate the built-in diagnostics and teach the command
to present warnings without turning them into failures. The reporter also
retains associated exceptions and additional files for the consolidated
log.

Cover command exit behavior and networking reports at the typed reporter
boundary.

Assisted-by: GPT-5.6 Sol Fast (Internal only)
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
The command now retains outcome, report, exception, and file data for each
diagnostic. Keeping presentation and file copying inside the execution loop
would make the summary depend on mutable counters and scatter the logging
rules.

Return a result from each run and aggregate those results before copying
files or printing the summary. Isolating header, exception, and presentation
logic keeps the command flow linear and gives later options one place to
decide how outcomes affect the exit status.

Assisted-by: GPT-5.6 Sol Fast (Internal only)
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Add a new --strict flag to the diagnose command to return a non-zero
result when warnings are emitted.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Use the default AnsiConsole from Spectre.Console to spruce up our
diagnostic terminal output.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>

@dscho dscho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular the "sprucing up" of the output should make those among us happy who insist on Quarter-by-Quarter Incremental Delivery, i.e. those who demand that every initiative/epic must come with a user-visible improvement 😉

Comment thread src/Core/Commands/DiagnoseCommand.cs Outdated
Comment on lines +108 to +114
ConsoleEx.WriteColor("[SKIP]", ConsoleColor.Gray);
ConsoleEx.WriteColor("[SKIP]", ConsoleColor.DarkGray);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that this fits the bill of "diagnose: report structured outcomes" ;-) But it does not really matter, I think, it's not like this introduces a regression.

_context = context;

var output = new Option<string>(new[] { "--output", "-o" }, "Output directory for diagnostic logs.");
var output = new Option<string>(["--output", "-o"], "Output directory for diagnostic logs.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I dislike those drive-by changes by AI, they increase the cognitive load for reviewers in unnecessary ways. But in this instance, it's a net readability improvement, so I don't mind as much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants