History

sketch a way to configure remotes

Sebastian Thiel committed 4 years ago

Commit 615a3a91 parent d7f495d1 file · +24 −1Browse files

Unified · Split

git-repository/src/clone.rs+24−1
@@ -2,6 +2,9 @@ · 1 unmodified line
2pub struct Prepare {2pub struct Prepare {
3 /// A freshly initialized repository which is owned by us, or `None` if it was handed to the user3 /// A freshly initialized repository which is owned by us, or `None` if it was handed to the user
4 repo: Option<crate::Repository>,4 repo: Option<crate::Repository>,
5 /// A function to configure a remote prior to fetching a pack.
6 configure_remote:
7 Option<Box<dyn FnOnce(crate::Remote<'_>) -> Result<crate::Remote<'_>, crate::remote::init::Error>>>,
5 /// The url to clone from8 /// The url to clone from
6 #[allow(dead_code)]9 #[allow(dead_code)]
7 url: git_url::Url,10 url: git_url::Url,
@@ -42,7 +45,27 @@ pub mod prepare { · 34 unmodified lines
42 {45 {
43 let url = url.try_into().map_err(git_url::parse::Error::from)?;46 let url = url.try_into().map_err(git_url::parse::Error::from)?;
44 let repo = crate::ThreadSafeRepository::init_opts(path, create_opts, open_opts)?.to_thread_local();47 let repo = crate::ThreadSafeRepository::init_opts(path, create_opts, open_opts)?.to_thread_local();
45 Ok(Prepare { url, repo: Some(repo) })48 Ok(Prepare {
49 url,
50 repo: Some(repo),
51 configure_remote: None,
52 })
53 }
54 }
55
56 /// Builder
57 impl Prepare {
58 /// Use `f` to apply arbitrary changes to the remote that is about to be used to fetch a pack.
59 ///
60 /// The passed in `remote` will be anonymous and pre-configured to be a default remote as we know it from git-clone.
61 /// It is not yet present in the configuration of the repository,
62 /// but each change it will eventually be written to the configuration prior to performing a the fetch operation.
63 pub fn configure_remote(
64 mut self,
65 f: impl FnOnce(crate::Remote<'_>) -> Result<crate::Remote<'_>, crate::remote::init::Error> + 'static,
66 ) -> Self {
67 self.configure_remote = Some(Box::new(f));
68 self
46 }69 }
47 }70 }
48 71

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t