Skip to content

feat: Add customizable conflict marker labels & Linting #41

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

shiueo
Copy link

@shiueo shiueo commented Jul 2, 2025

Summary

This PR adds the ability to customize conflict marker labels in merge operations, allowing users to specify custom labels instead of the default "ours", "theirs", and "original".

Changes

  • Added ours_label, theirs_label, and original_label fields to MergeOptions
  • Added methods to set individual labels: set_ours_label(), set_theirs_label(), set_original_label()
  • Added convenience method set_conflict_labels() to set all labels at once
  • Updated output_result() and output_result_bytes() functions to use custom labels

Example Usage

let result = MergeOptions::new()
    .set_ours_label("main")
    .set_theirs_label("feature-branch")
    .set_original_label("base")
    .merge(ancestor, ours, theirs);

let result = MergeOptions::new()
    .set_conflict_labels("HEAD", "incoming", "common-ancestor")
    .merge(ancestor, ours, theirs);

Backward Compatibility

This change is fully backward compatible. Existing code will continue to work with the default labels ("ours", "theirs", "original").

shiueo added 10 commits July 2, 2025 11:57
Introduces fields and setter methods in MergeOptions to allow custom labels for 'ours', 'theirs', and 'original' in merge conflict markers. Updates merge output functions to use these labels, enabling more descriptive and flexible conflict markers.
Refactored the set_conflict_labels method signature to use multi-line formatting, improving code readability and consistency with Rust style guidelines.
Updated the CI workflow to run cargo clippy with --all-features and treat all warnings as errors by adding -D warnings. This ensures stricter linting and code quality enforcement during continuous integration.
Updated CI workflow to run clippy without --all-features for broader compatibility. Changed clippy lint attributes in merge module from warn to allow for too_many_arguments to suppress warnings.
Replaced instances of format macros with explicit variable interpolation (e.g., writeln!(f, "{var}") instead of writeln!(f, "{}", var)) in src/patch/format.rs and src/range.rs. This improves code readability and consistency with modern Rust formatting practices.
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