Skip to content

Format dependency failure output as an indented tree#324

Merged
kindermax merged 3 commits intomasterfrom
codex/use-two-spaces-for-tree
Mar 27, 2026
Merged

Format dependency failure output as an indented tree#324
kindermax merged 3 commits intomasterfrom
codex/use-two-spaces-for-tree

Conversation

@kindermax
Copy link
Copy Markdown
Collaborator

@kindermax kindermax commented Mar 27, 2026

Summary

  • route dependency failure trees through the logger so the lets: prefix stays formatter-owned
  • add DependencyError.TreeMessage() to render a command failed: block with two-space indentation and └─ joints
  • preserve the final failure status line and update changelog and tree output assertions

Testing

  • lets fmt
  • go test ./internal/executor -run "TestDependencyErrorFailureMessage|TestPrintDependencyTree" -v
  • lets test-bats dependency_failure_tree.bats
  • go test ./...

Summary by Sourcery

Format dependency failure output as a structured, indented tree message routed through the logger while preserving the final failure status line.

Enhancements:

  • Introduce DependencyError.TreeMessage to render a multi-line, indented dependency failure tree with clear joint markers and failure annotation.
  • Refine PrintDependencyTree to delegate to DependencyError.TreeMessage for consistent tree formatting and output.
  • Update CLI error handling to log the formatted dependency tree via the logger instead of writing directly to stderr.
  • Adjust dependency failure tests to assert on the new tree layout and header format, and document the behavior change in the changelog.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 27, 2026

Reviewer's Guide

Refactors dependency failure reporting so that dependency trees are rendered by DependencyError.TreeMessage() as an indented, jointed "command failed:" block routed through the logger, while preserving a separate final failure status line and updating tests and docs accordingly.

Sequence diagram for new dependency failure logging flow

sequenceDiagram
  actor User
  participant CLI
  participant Executor
  participant Logger
  participant Stderr

  User->>CLI: run failing command
  CLI->>Executor: execute command with dependencies
  Executor-->>CLI: error DependencyError

  CLI->>Logger: Errorf(%s, depErr.TreeMessage())
  Logger->>Stderr: lets: command failed: block with indented tree

  CLI->>Logger: Errorf(%s, depErr.FailureMessage())
  Logger->>Stderr: lets: exit status N
Loading

Class diagram for updated DependencyError and dependency tree printing

classDiagram

class DependencyError {
  []string Chain
  error Err
  Error() string
  Unwrap() error
  FailureMessage() string
  TreeMessage() string
}

class ExecutorPackage {
  +PrintDependencyTree(e DependencyError, w io.Writer) void
}

class ColorPackage
class IoWriter

ExecutorPackage ..> DependencyError : uses
ExecutorPackage ..> IoWriter : writes_to
DependencyError ..> ColorPackage : colors_failure_marker
Loading

File-Level Changes

Change Details Files
Refactor dependency tree rendering into DependencyError.TreeMessage with a standardized indented tree format.
  • Introduce constants for dependency tree header, indent, and joint characters.
  • Add DependencyError.TreeMessage to build a multi-line "command failed:" block with two-space indentation, └─ joints, and a red "<-- failed here" marker on the failing command.
  • Update PrintDependencyTree to delegate to TreeMessage instead of manually formatting and writing each line.
internal/executor/dependency_error.go
Route dependency failure tree output through the logger instead of writing directly to stderr.
  • Change CLI error handling to log the dependency tree via log.Errorf using DependencyError.TreeMessage.
  • Keep logging of the final failure status line via DependencyError.FailureMessage unchanged to preserve the separate status line.
internal/cli/cli.go
Align tests and documentation with the new dependency tree output format.
  • Update Go unit tests to assert the new multi-line dependency tree structure, including header, indentation, and joints.
  • Adjust Bats integration tests to match the logger-prefixed "command failed:" block and shifted line indices for the final status line.
  • Revise changelog entry to describe the new logger-prefixed block format for command failure output.
internal/executor/dependency_error_test.go
tests/dependency_failure_tree.bats
docs/docs/changelog.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kindermax kindermax merged commit caa90c6 into master Mar 27, 2026
5 checks passed
@kindermax kindermax deleted the codex/use-two-spaces-for-tree branch March 27, 2026 17:49
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.

1 participant