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
22 pub struct Prepare {
33 /// A freshly initialized repository which is owned by us, or `None` if it was handed to the user
44 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>>>,
58 /// The url to clone from
69 #[allow(dead_code)]
710 url: git_url::Url,
@@ -42,7 +45,27 @@ pub mod prepare { · 34 unmodified lines
4245 {
4346 let url = url.try_into().map_err(git_url::parse::Error::from)?;
4447 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
4669 }
4770 }
4871

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