File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,34 @@ impl Index {
70
70
/// let index = Index::from_path_or_cloned_with_options(path, options)?;
71
71
/// # Ok::<(), git2::Error>(())
72
72
/// ```
73
+ /// Or to access a private repository, use fetch options.
74
+ ///
75
+ /// ```no_run
76
+ /// use crates_index_diff::{CloneOptions, Index};
77
+ /// let fo = {
78
+ /// let mut fo = git2::FetchOptions::new();
79
+ /// fo.remote_callbacks({
80
+ /// let mut callbacks = git2::RemoteCallbacks::new();
81
+ /// callbacks.credentials(|_url, username_from_url, _allowed_types| {
82
+ /// git2::Cred::ssh_key_from_memory(
83
+ /// username_from_url.unwrap(),
84
+ /// None,
85
+ /// &std::env::var("PRIVATE_KEY").unwrap(),
86
+ /// None,
87
+ /// )
88
+ /// });
89
+ /// callbacks
90
+ /// });
91
+ /// fo
92
+ /// };
93
+ /// Index::from_path_or_cloned_with_options(
94
+ /// "index",
95
+ /// CloneOptions {
96
+ /// repository_url: "[email protected] :private-index/goes-here.git".into(),
97
+ /// fetch_options: Some(fo),
98
+ /// },
99
+ /// ).unwrap();
100
+ /// ```
73
101
pub fn from_path_or_cloned_with_options (
74
102
path : impl AsRef < Path > ,
75
103
CloneOptions {
You can’t perform that action at this time.
0 commit comments