Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 27, 2025

This PR implements the missing std::fmt::Display trait for the reference name types in gix-ref, completing the Display implementation coverage for all reference name types.

Changes

  • FullNameRef: Added Display implementation to gix-ref/src/fullname.rs
  • PartialName: Added Display implementation to gix-ref/src/name.rs
  • PartialNameRef: Added Display implementation to gix-ref/src/name.rs

All implementations follow the same pattern as the existing FullName Display implementation by delegating to the underlying BString/BStr Display implementation.

Usage

With these changes, users can now format all reference name types consistently:

use gix_ref::{FullName, PartialName};
use std::convert::TryFrom;

// FullName (already worked)
let full_name = FullName::try_from("refs/heads/main").unwrap();
println!("{}", full_name); // "refs/heads/main"

// FullNameRef (now works)
let full_name_ref = full_name.as_ref();
println!("{}", full_name_ref); // "refs/heads/main"

// PartialName (now works)  
let partial_name = PartialName::try_from("heads/main").unwrap();
println!("{}", partial_name); // "heads/main"

// PartialNameRef (now works)
let partial_name_ref = partial_name.as_ref();
println!("{}", partial_name_ref); // "heads/main"

Testing

Added comprehensive tests covering all four reference name types with various reference patterns (branches, remotes, tags, HEAD, etc.) to ensure the Display implementations work correctly with both format!() and .to_string().

All existing tests continue to pass, confirming no regressions were introduced.

Original prompt

Implement std::fmt::Display for gix_ref::FullName and gix_ref::FullNameRef. Do the same for PartialName and PartialNameRef for completeness.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI assigned Copilot and Byron Sep 27, 2025
@Copilot Copilot AI changed the title [WIP] Implement std::fmt::Display for gix_ref::FullName and gix_ref::FullNameRef. Do the same for PartialName and PartialNameRef for completeness. Implement std::fmt::Display for FullNameRef, PartialName, and PartialNameRef Sep 27, 2025
@Copilot Copilot AI requested a review from Byron September 27, 2025 14:50
Copilot finished work on behalf of Byron September 27, 2025 14:50
Copilot AI and others added 2 commits September 27, 2025 20:20
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
@Byron Byron force-pushed the copilot/fix-713956e8-cf8b-499a-99a8-92001948c9f8 branch from 3731de4 to e670294 Compare September 27, 2025 18:40
@Byron Byron marked this pull request as ready for review September 27, 2025 18:41
@Byron Byron enabled auto-merge September 27, 2025 18:41
@Byron Byron merged commit 0a576b9 into main Sep 27, 2025
29 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.

2 participants