1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::Index;
use git_repository as git;
use std::str;
static INDEX_GIT_URL: &str = "https://github.com/rust-lang/crates.io-index";
static LAST_SEEN_REFNAME: &str = "refs/heads/crates-index-diff_last-seen";
pub struct CloneOptions<'a> {
pub repository_url: String,
pub fetch_options: Option<git2::FetchOptions<'a>>,
}
impl<'a> Default for CloneOptions<'a> {
fn default() -> Self {
CloneOptions {
repository_url: INDEX_GIT_URL.into(),
fetch_options: None,
}
}
}
impl Index {
pub fn repository(&self) -> &git::Repository {
&self.repo
}
pub fn repository_mut(&mut self) -> &mut git::Repository {
&mut self.repo
}
pub fn last_seen_reference(
&self,
) -> Result<git::Reference<'_>, git::reference::find::existing::Error> {
self.repo.find_reference(self.seen_ref_name)
}
}
pub mod diff;
pub mod init;