Skip to content

Commit

Permalink
fix: connect before fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
kudlatyamroth committed Dec 14, 2023
1 parent bab532e commit 5318f05
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/schematools/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Discovery {
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Registry {
pub path: PathBuf,
}
Expand Down Expand Up @@ -153,8 +153,14 @@ pub fn discover_git(
let repo = git2::Repository::init(directory.clone()).map_err(Error::GitDiscoveryError)?;
let mut opts = git2::FetchOptions::new();

repo.remote_anonymous(repository)
.map_err(Error::GitDiscoveryError)?
let mut remote = repo.remote_anonymous(repository)
.map_err(Error::GitDiscoveryError)?;

remote
.connect(git2::Direction::Fetch)
.map_err(Error::GitDiscoveryError)?;

remote
.fetch(&refspecs, Some(&mut opts), None)
.map_err(Error::GitDiscoveryError)?;

Expand Down Expand Up @@ -183,6 +189,7 @@ mod tests {
false,
)
.unwrap();
println!("registry {:?}", registry.clone().path);
discovery.register("testing".to_string(), registry);

let result = discovery
Expand Down

0 comments on commit 5318f05

Please sign in to comment.