pub struct GitRepository { /* private fields */ }Expand description
A repository rooted at a discovered worktree.
Implementations§
Source§impl GitRepository
impl GitRepository
Sourcepub fn discover(path: impl AsRef<Path>) -> Result<Self, GitError>
pub fn discover(path: impl AsRef<Path>) -> Result<Self, GitError>
Discover the worktree containing path.
pub fn root(&self) -> &Path
pub fn git_processes(&self) -> usize
Sourcepub fn default_ref(&self) -> Result<Option<String>, GitError>
pub fn default_ref(&self) -> Result<Option<String>, GitError>
Return the current branch’s upstream/default ref when available.
Detached repositories can still use a local main or master ref;
absent refs return None instead of inventing a comparison base.
Sourcepub fn commits_ahead(&self, base: &str) -> Result<BTreeSet<String>, GitError>
pub fn commits_ahead(&self, base: &str) -> Result<BTreeSet<String>, GitError>
The commits this worktree holds that the base does not.
A diff asks what a change did, and the change is exactly this set: the history before it is the history without them. The answer is a set of revisions rather than a count, so a streamed commit can say which side of the change it belongs to.
pub fn merge_base(&self, left: &str, right: &str) -> Result<String, GitError>
Sourcepub fn changes_from(&self, base: &str) -> Result<Vec<Change>, GitError>
pub fn changes_from(&self, base: &str) -> Result<Vec<Change>, GitError>
Returns the sorted, unique source changes visible from a base ref.
Sourcepub fn stream_history(
&self,
since: Option<i64>,
accept: impl FnMut(HistoryCommit) -> Result<(), GitError>,
) -> Result<HistoryStreamSummary, GitError>
pub fn stream_history( &self, since: Option<i64>, accept: impl FnMut(HistoryCommit) -> Result<(), GitError>, ) -> Result<HistoryStreamSummary, GitError>
Stream non-merge history through one Git process. When since selects
a window cutoff, the filter runs inside the Git process itself, so
commits that landed before the cutoff are never streamed; both the
process filter and each commit’s timestamp describe the landed
(committer) date, so the two can never disagree. Only one commit is
retained by this adapter at a time.
Sourcepub fn object_reader(
&self,
max_pending: usize,
) -> Result<ObjectReader, GitError>
pub fn object_reader( &self, max_pending: usize, ) -> Result<ObjectReader, GitError>
Start one git cat-file --batch process. Keep this reader alive across
requests to avoid one process per changed file.