Skip to content

feat: Implement Git Note object parsing and generation#8

Merged
genedna merged 1 commit into
libra-tools:mainfrom
AllureCurtain:feat/note
Oct 2, 2025
Merged

feat: Implement Git Note object parsing and generation#8
genedna merged 1 commit into
libra-tools:mainfrom
AllureCurtain:feat/note

Conversation

@AllureCurtain

Copy link
Copy Markdown
Contributor

Resolves #6

🚀 Git Note Object Demo - Best Practices

1️⃣ Creating a new Note object:
Target Commit: a1b2c3d4e5f6789012345678901234567890abcd
Note ID: fb56a5ae9f02fa5bc750e08a9a9a9d250795bfd3
Content: Code review: LGTM! Great implementation.
Size: 40 bytes

2️⃣ Serializing Note with target association:
Serialized size: 40 bytes
Target object ID: a1b2c3d4e5f6789012345678901234567890abcd
Git object format: blob 40\0
Raw data preview: [67, 111, 100, 101, 32, 114, 101, 118, 105, 101, 119, 58, 32, 76, 71, 84, 77, 33, 32, 71, 114, 101, 97, 116, 32, 105, 109, 112, 108, 101]...

3️⃣ Basic deserialization (ObjectTrait):
Successfully deserialized!
Target Commit: 0000000000000000000000000000000000000000 (default - target managed externally)
Content: Code review: LGTM! Great implementation.
Content matches: true

4️⃣ Best practice deserialization (with target):
Successfully deserialized with target!
Target Commit: a1b2c3d4e5f6789012345678901234567890abcd
Content: Code review: LGTM! Great implementation.
Complete objects are equal: true

Resolves libra-tools#6

Signed-off-by: allure <1550220889@qq.com>
@genedna genedna added enhancement New feature or request r2cn labels Oct 2, 2025
@genedna genedna requested a review from Copilot October 2, 2025 11:55

Copilot AI 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.

Pull Request Overview

This PR implements Git Note object parsing and generation functionality, adding support for Git's note system which allows attaching metadata to existing Git objects without modifying them.

  • Adds a complete Note struct with creation, serialization, and deserialization methods
  • Implements the ObjectTrait for Git object database integration
  • Provides both basic and target-aware deserialization methods for different use cases

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/internal/object/note.rs Complete Note object implementation with comprehensive API and tests
src/internal/object/mod.rs Exports the new note module
src/errors.rs Adds InvalidNoteObject error variant for Note-specific errors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +38 to +43
impl PartialEq for Note {
/// Two Notes are equal if they have the same ID
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}

Copilot AI Oct 2, 2025

Copy link

Choose a reason for hiding this comment

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

The PartialEq implementation only compares IDs, but Notes with different target_object_id or content could have the same ID if they have identical content. Consider comparing all fields or documenting why only ID comparison is intentional.

Copilot uses AI. Check for mistakes.
println!(" Serialized size: {} bytes", serialized_data.len());
println!(" Target object ID: {}", target_id);
println!(
" Git object format: blob {}\\0<content>",

Copilot AI Oct 2, 2025

Copy link

Choose a reason for hiding this comment

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

The escaped backslash in the format string should be a literal null character. Change \\0 to \0 to properly represent the null byte separator in Git object format.

Copilot uses AI. Check for mistakes.
@genedna genedna merged commit 1673bc5 into libra-tools:main Oct 2, 2025
@github-actions github-actions Bot mentioned this pull request Feb 10, 2026
genedna pushed a commit to genedna/git-internal that referenced this pull request Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request r2cn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[r2cn] 增加 Note 对象的解析和生成

3 participants