8000 Add branch-info test by da-moon · Pull Request #6 · da-moon/gitoxide · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add branch-info test #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025

Conversation

da-moon
Copy link
Owner
@da-moon da-moon commented Jun 14, 2025

Summary

  • add tests/journey/branch-info.sh for end-to-end coverage
  • remove obsolete tests/journey.sh harness

Testing

  • cargo check-short
  • cargo test-short

https://chatgpt.com/codex/tasks/task_e_684a09c8b3788320be95f67cc89f442c

Summary by Sourcery

Add a new branch-info CLI tool to the workspace with associated build configuration and end-to-end tests, and clean up the old test harness.

New Features:

  • Introduce branch-info CLI tool to display the current branch, list commits, or show diffs between commits.

Build:

  • Register the branch-info crate in the workspace Cargo.toml and add its own Cargo.toml.

Tests:

  • Add end-to-end journey test script for branch-info listing commits and diff output.

Chores:

  • Remove the obsolete tests/journey.sh harness file.

Copy link
sourcery-ai bot commented Jun 14, 2025

Reviewer's Guide

Integrate a new branch-info CLI into the workspace for listing commits or showing diffs against the upstream branch, and add an end-to-end journey test for its behavior while removing the obsolete test harness.

Sequence Diagram for branch-info Commit Listing

sequenceDiagram
    actor User
    participant CLI_Main as "branch-info:main()"
    participant Args_Instance as "Args.run()"
    participant BranchInfoHelpers as "branch-info:helpers"
    participant GixLib as "gix Library"

    User->>CLI_Main: execute `branch-info`
    CLI_Main->>Args_Instance: Args::parse() then run()
    activate Args_Instance

    Args_Instance->>GixLib: gix::discover()
    GixLib-->>Args_Instance: repo
    Args_Instance->>GixLib: Resolve 'to_id' (e.g., head_id(), rev_parse_single())
    GixLib-->>Args_Instance: to_id
    Args_Instance->>BranchInfoHelpers: detect_base(repo, head_id) / gix.rev_parse_single() (for 'from_id')
    activate BranchInfoHelpers
    BranchInfoHelpers-->>Args_Instance: from_id
    deactivate BranchInfoHelpers

    Args_Instance->>BranchInfoHelpers: list_commits(repo, from_id, to_id)
    activate BranchInfoHelpers
        BranchInfoHelpers->>GixLib: repo.rev_walk([to_id]).with_boundary([from_id]).all()
        GixLib-->>BranchInfoHelpers: commit_infos
        loop For each commit_info
            BranchInfoHelpers->>GixLib: commit_info.object()
            GixLib-->>BranchInfoHelpers: commit
            BranchInfoHelpers->>GixLib: commit.message().summary()
            GixLib-->>BranchInfoHelpers: summary
            BranchInfoHelpers->>CLI_Main: Output commit_id and summary
        end
    deactivate BranchInfoHelpers
    deactivate Args_Instance
    CLI_Main-->>User: Displays list of commits
Loading

Sequence Diagram for branch-info Diff Display

sequenceDiagram
    actor User
    participant CLI_Main as "branch-info:main()"
    participant Args_Instance as "Args.run()"
    participant BranchInfoHelpers as "branch-info:helpers"
    participant GixLib as "gix Library"

    User->>CLI_Main: execute `branch-info --show-diff`
    CLI_Main->>Args_Instance: Args::parse() then run()
    activate Args_Instance

    Args_Instance->>GixLib: gix::discover()
    GixLib-->>Args_Instance: repo
    Args_Instance->>GixLib: Resolve 'to_id' (e.g., head_id(), rev_parse_single())
    GixLib-->>Args_Instance: to_id
    Args_Instance->>BranchInfoHelpers: detect_base(repo, head_id) / gix.rev_parse_single() (for 'from_id')
    activate BranchInfoHelpers
    BranchInfoHelpers-->>Args_Instance: from_id
    deactivate BranchInfoHelpers

    Args_Instance->>BranchInfoHelpers: show_patch(repo, from_id, to_id)
    activate BranchInfoHelpers
        BranchInfoHelpers->>GixLib: find_commit(from_id)
        GixLib-->>BranchInfoHelpers: lhs_commit
        BranchInfoHelpers->>GixLib: find_commit(to_id)
        GixLib-->>BranchInfoHelpers: rhs_commit
        BranchInfoHelpers->>GixLib: lhs_commit.tree()
        GixLib-->>BranchInfoHelpers: lhs_tree
        BranchInfoHelpers->>GixLib: rhs_commit.tree()
        GixLib-->>BranchInfoHelpers: rhs_tree
        BranchInfoHelpers->>GixLib: repo.diff_tree_to_tree(lhs_tree, rhs_tree)
        GixLib-->>BranchInfoHelpers: changes
        loop For each change
            BranchInfoHelpers->>BranchInfoHelpers: print_patch(cache, change)
            activate BranchInfoHelpers
                BranchInfoHelpers->>GixLib: change.diff(cache)
                GixLib-->>BranchInfoHelpers: platform_diff
                BranchInfoHelpers->>GixLib: (further gix calls for diff content)
                GixLib-->>BranchInfoHelpers: diff_lines
                BranchInfoHelpers->>CLI_Main: Output diff_lines
            deactivate BranchInfoHelpers
        end
    deactivate BranchInfoHelpers
    deactivate Args_Instance
    CLI_Main-->>User: Displays full diff
Loading

File-Level Changes

Change Details Files
Introduce branch-info CLI application
  • Added branch-info to workspace members
  • Created branch-info crate with its own Cargo.toml
  • Implemented argument parsing, branch detection, commit listing, and diff display in main.rs
Cargo.toml
Cargo.lock
branch-info/Cargo.toml
branch-info/src/main.rs
Add end-to-end journey test and remove old harness
  • Added tests/journey/branch-info.sh with snapshot-based commit and diff validation
  • Removed obsolete tests/journey.sh test harness
tests/journey/branch-info.sh
tests/journey.sh

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

@da-moon da-moon merged commit 03240ca into main Jun 14, 2025
@da-moon da-moon deleted the codex/add-branch-info-crate-and-implementation branch June 14, 2025 00:43
Copy link
@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 @da-moon - 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0