pub struct GitDiffSource { /* private fields */ }Expand description
Scans only the ADDED lines between two git refs.
Uses git diff unified diff output and extracts lines starting with ‘+’.
Useful for CI/CD pre-commit hooks and PR checks.
§Examples
use keyhog_core::Source;
use keyhog_sources::GitDiffSource;
use std::path::PathBuf;
let source = GitDiffSource::new(PathBuf::from("."), "main").with_head_ref("HEAD");
assert_eq!(source.name(), "git-diff");Implementations§
Source§impl GitDiffSource
impl GitDiffSource
Sourcepub fn new(repo_path: PathBuf, base_ref: impl Into<String>) -> Self
pub fn new(repo_path: PathBuf, base_ref: impl Into<String>) -> Self
Create a new diff source comparing base_ref to HEAD.
§Examples
use keyhog_core::Source;
use keyhog_sources::GitDiffSource;
use std::path::PathBuf;
let source = GitDiffSource::new(PathBuf::from("."), "origin/main");
assert_eq!(source.name(), "git-diff");Sourcepub fn with_head_ref(self, head_ref: impl Into<String>) -> Self
pub fn with_head_ref(self, head_ref: impl Into<String>) -> Self
Set a specific head ref to compare against (defaults to HEAD).
§Examples
use keyhog_core::Source;
use keyhog_sources::GitDiffSource;
use std::path::PathBuf;
let source = GitDiffSource::new(PathBuf::from("."), "main").with_head_ref("feature");
assert_eq!(source.name(), "git-diff");Trait Implementations§
Source§impl Source for GitDiffSource
impl Source for GitDiffSource
Auto Trait Implementations§
impl Freeze for GitDiffSource
impl RefUnwindSafe for GitDiffSource
impl Send for GitDiffSource
impl Sync for GitDiffSource
impl Unpin for GitDiffSource
impl UnsafeUnpin for GitDiffSource
impl UnwindSafe for GitDiffSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more