Skip to content

Commit

Permalink
Merge pull request #13 from breezy-team/ci-format
Browse files Browse the repository at this point in the history
Check formatting in CI
  • Loading branch information
jelmer authored Sep 24, 2024
2 parents 5a30003 + d9e4e2f commit 45124f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ jobs:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
env:
RUSTFLAGS: -Dwarnings
- name: Run tests
run: cargo test --verbose
env:
RUSTFLAGS: -Dwarnings
- name: Check formatting
run: cargo fmt -- --check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
*~
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Given BASE, OTHER, THIS, tries to produce a combined text
incorporating the changes from both BASE->OTHER and BASE->THIS.
All three will typically be sequences of lines.

The implementation is primarily meant to be used with text files, but
it should work with any type that can be represented as a sequence of
lines.

Usage
=====

Expand Down
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
//! incorporating the changes from both BASE->OTHER and BASE->THIS.
//! All three will typically be sequences of lines.
//!
//! While the primary use case is for text, the implementation is generic and can be used with any
//! type that implements Eq and Hash.
//!
//! ## Example
//!
//! ```rust
Expand Down Expand Up @@ -58,7 +61,6 @@ fn compare_range<T: PartialEq>(
/// Given BASE, OTHER, THIS, tries to produce a combined text incorporating the changes from both
/// BASE->OTHER and BASE->THIS. All three will typically be sequences of lines, but don't have to
/// be.

pub struct Merge3<'b, T: Eq + std::hash::Hash + ?Sized> {
// Lines in BASE
base: &'b [&'b T],
Expand Down Expand Up @@ -609,6 +611,11 @@ pub enum MergeGroup<'a, T: Eq> {
Conflict(Option<&'a [T]>, &'a [T], &'a [T]),
}

/// Markers for a merge.
///
/// These are used to provide context for a merge conflict.
/// The markers are inserted into the merged text to show where the conflicts are.
/// The markers are typically used to show the start and end of a conflict region.
pub trait LineMarkers<'a, T: ToOwned + ?Sized> {
fn start_marker(&self) -> Option<Cow<'a, T>>;
fn base_marker(&self) -> Option<Cow<'a, T>>;
Expand Down Expand Up @@ -684,6 +691,7 @@ impl<'a> LineMarkers<'a, [u8]> for StandardMarkers<'a> {
}
}

/// Custom markers for 3-way merge.
#[derive(Default)]
pub struct CustomMarkers<'a> {
pub start_marker: Option<&'a str>,
Expand Down

0 comments on commit 45124f8

Please sign in to comment.