-
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.
Make sure all cache access is encapsulated in the ProtofetchGitCache
- Loading branch information
Showing
12 changed files
with
182 additions
and
183 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<()> { | ||
self.clone_or_update(coordinate)? | ||
.resolve_commit_hash(specification)?; | ||
Ok(()) | ||
} | ||
|
||
fn create_worktree( | ||
&self, | ||
coordinate: &Coordinate, | ||
commit_hash: &str, | ||
name: &DependencyName, | ||
) -> anyhow::Result<PathBuf> { | ||
let path = self | ||
.clone_or_update(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.