Skip to content

Comments

feat(blame, diff): add blame support, bump the git-internal version#70

Merged
genedna merged 2 commits intoweb3infra-foundation:mainfrom
muzaffarmhd:feat/diff-and-blame
Nov 29, 2025
Merged

feat(blame, diff): add blame support, bump the git-internal version#70
genedna merged 2 commits intoweb3infra-foundation:mainfrom
muzaffarmhd:feat/diff-and-blame

Conversation

@muzaffarmhd
Copy link
Contributor

@muzaffarmhd muzaffarmhd commented Nov 28, 2025

This Pull Request implements the libra blame command to show line-by-line commit attribution for files. The command walks backward through commit history using diff to track which commit last modified each line, with support for line range filtering (-L) and Git-compatible output formatting with timezone-aware timestamps piped through a pager. It bumps the git-internal dependency from version 0.1.0 to 0.2.2, which includes an updated diff implementation. The changes migrate diff operations from a local diff_engine module to the git-internal crate and add comprehensive blame support with line range selection.

Key Changes

  • Added new blame command with line-range support and formatted output
  • Migrated diff functionality from local implementation to git-internal crate (version 0.2.2)
  • Updated tests to use tempfile for better isolation instead of shared test utilities
  • Added colorized diff output for terminal display

Notes:

  1. In tests/command/log_test.rs The test values for insertions and deletions have changed from (4, 3) to (2, 1) because the previous version used a naive diff that marked ALL old lines as deleted and ALL new lines as inserted, and the tests were correct for previous version, so updated the tests.

  2. The current diff implementation doesn't support algorithm option, whilst the option can be provided, it serves no real purpose as of current implementation, if the the git-internal crate can be updated with algorithm support, the same can be added to libra.

[ This is a pre-task and part of r2cn and fixes #64 ]

additionally use the updated diff from git-internal crate, colorize the diff output, fix compatibility issues from version bump
Copilot AI review requested due to automatic review settings November 28, 2025 10:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new libra blame command to show line-by-line commit attribution for files with support for line range filtering and Git-compatible formatted output. It also migrates diff functionality from a local diff_engine module to the git-internal crate (version 0.2.2) and refactors tests to use tempfile for better isolation.

Key changes:

  • New blame command implementation with line-range support and timezone-aware timestamps
  • Migration of diff operations from local implementation to git-internal crate v0.2.2
  • Colorized diff output for terminal display
  • Test refactoring to use tempfile instead of shared utilities

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/command/blame.rs New blame command implementation with history walking and line attribution
src/command/diff.rs Migrated to git-internal Diff API, added colorization, removed algorithm parameter
src/command/push.rs Updated to use MetaAttached wrapper for Entry objects
src/command/index_pack.rs Updated pack.decode() signature to accept MetaAttached entries
src/command/log.rs Updated to use git-internal Diff API
src/command/mod.rs Added blame module export
src/cli.rs Added Blame command and routing
src/lib.rs Removed diff_engine module
src/utils/lfs.rs Refactored test to use tempfile for better isolation
src/internal/protocol/lfs_client.rs Refactored test to use tempfile
tests/command/log_test.rs Updated test expectations and migrated to git-internal Diff API
Cargo.toml Bumped git-internal from 0.1.0 to 0.2.2
Cargo.lock Updated dependencies

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.

@muzaffarmhd
Copy link
Contributor Author

@genedna This Pull Request is ready for review/merge after applying all the suggested changes by copilot and fixing build errors.

@genedna genedna requested a review from Copilot November 28, 2025 16:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 299 out of 389 changed files in this pull request and generated no new comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 299 out of 389 changed files in this pull request and generated no new comments.

Copy link

@231220075 231220075 left a comment

Choose a reason for hiding this comment

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

LGTM.

@benjamin-747 benjamin-747 self-requested a review November 29, 2025 03:24
Copy link
Collaborator

@benjamin-747 benjamin-747 left a comment

Choose a reason for hiding this comment

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

LGTM

@genedna genedna merged commit 39077d2 into web3infra-foundation:main Nov 29, 2025
5 checks passed
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.

[r2cn-测试任务] Add libra blame command

4 participants