-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not access remotes unless necessary (#115)
* Make cache::clear part of ProtofetchGitCache * Make sure all cache access is encapsulated in the ProtofetchGitCache * Do not access remotes unless necessary
- Loading branch information
Showing
12 changed files
with
247 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::path::PathBuf; | ||
|
||
use crate::{ | ||
git::cache::ProtofetchGitCache, | ||
model::protofetch::{Coordinate, DependencyName, RevisionSpecification}, | ||
}; | ||
|
||
use super::RepositoryCache; | ||
|
||
impl RepositoryCache for ProtofetchGitCache { | ||
fn fetch( | ||
&self, | ||
coordinate: &Coordinate, | ||
specification: &RevisionSpecification, | ||
commit_hash: &str, | ||
) -> anyhow::Result<()> { | ||
let repository = self.repository(coordinate)?; | ||
repository.fetch_commit(specification, commit_hash)?; | ||
Ok(()) | ||
} | ||
|
||
fn create_worktree( | ||
&self, | ||
coordinate: &Coordinate, | ||
commit_hash: &str, | ||
name: &DependencyName, | ||
) -> anyhow::Result<PathBuf> { | ||
let path = self | ||
.repository(coordinate)? | ||
.create_worktree(name, commit_hash)?; | ||
Ok(path) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
mod git; | ||
|
||
use std::path::PathBuf; | ||
|
||
use crate::model::protofetch::{Coordinate, DependencyName, RevisionSpecification}; | ||
|
||
pub trait RepositoryCache { | ||
fn fetch( | ||
&self, | ||
coordinate: &Coordinate, | ||
specification: &RevisionSpecification, | ||
commit_hash: &str, | ||
) -> anyhow::Result<()>; | ||
|
||
fn create_worktree( | ||
&self, | ||
coordinate: &Coordinate, | ||
commit_hash: &str, | ||
name: &DependencyName, | ||
) -> anyhow::Result<PathBuf>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod cache; | ||
pub mod repository; |
Oops, something went wrong.