pub struct Repo { /* private fields */ }Implementations§
Source§impl Repo
impl Repo
Sourcepub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> Self
pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> Self
Create a new instance of a Repository
§Examples:
use gitstats::Repo;
fn main() {
let repo_dir = "#/custom/path/to/repo";
let repo = Repo::from(&repo_dir);
}pub fn to_str(&self) -> Option<&str>
Sourcepub fn fetch(&self) -> Result<()>
pub fn fetch(&self) -> Result<()>
Fetch the repository using the default remote
§Examples:
use gitstats::Repo;
fn main() {
let repo_dir = "/custom/path/to/repo";
let repo = Repo::from(&repo_dir);
match repo.fetch() {
Ok(_) => println!("fetch complete"),
Err(err) => println!("Error: {err}"),
}
}Sourcepub fn list_commits(&self, options: CommitArgs) -> Result<Vec<CommitHash>>
pub fn list_commits(&self, options: CommitArgs) -> Result<Vec<CommitHash>>
Returns a list of commits based on the input arguments
§Examples:
use gitstats::Repo;
use gitstats::CommitArgs;
fn main() {
let repo_dir = "/custom/path/to/repo";
let repo = Repo::from(&repo_dir);
let commit_args = CommitArgs::default();
match repo.list_commits(commit_args) {
Ok(commits) => println!("got commits: {commits}"),
Err(err) => println!("Error: {err}"),
}
}pub fn first_commit(&self) -> Result<Option<CommitDetail>>
pub fn last_commit(&self) -> Result<Option<CommitDetail>>
Sourcepub fn commits_count(&self) -> Result<usize>
pub fn commits_count(&self) -> Result<usize>
Returns the total commits
pub fn details(&self) -> Result<Detail>
Sourcepub fn commits_stats(
&self,
commits: &Vec<CommitHash>,
) -> Result<Vec<CommitDetail>>
pub fn commits_stats( &self, commits: &Vec<CommitHash>, ) -> Result<Vec<CommitDetail>>
Extract details from a list of commits
§Examples:
use gitstats::Repo;
use gitstats::CommitArgs;
fn main() {
let repo_dir = "/custom/path/to/repo";
let repo = Repo::from(&repo_dir);
let commit_args = CommitArgs::default();
if let Ok(commits) = repo.list_commits(commit_args) {
let stats = repo.commits_stats(&commits);
}
}
Sourcepub fn commit_stats(&self, commit: CommitHash) -> Result<CommitDetail>
pub fn commit_stats(&self, commit: CommitHash) -> Result<CommitDetail>
Extract details from a commit hash
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Repo
impl RefUnwindSafe for Repo
impl Send for Repo
impl Sync for Repo
impl Unpin for Repo
impl UnwindSafe for Repo
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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