diff options
Diffstat (limited to 'test_utils/src/git.rs')
| -rw-r--r-- | test_utils/src/git.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test_utils/src/git.rs b/test_utils/src/git.rs index 7dfa62b..4a4aaa8 100644 --- a/test_utils/src/git.rs +++ b/test_utils/src/git.rs | |||
| @@ -123,6 +123,15 @@ impl GitTestRepo { | |||
| 123 | }) | 123 | }) |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | pub fn clone_repo(existing_repo: &GitTestRepo) -> Result<Self> { | ||
| 127 | let path = current_dir()?.join(format!("tmpgit-{}", rand::random::<u64>())); | ||
| 128 | let git_repo = git2::Repository::clone(existing_repo.dir.to_str().unwrap(), path.clone())?; | ||
| 129 | Ok(Self { | ||
| 130 | dir: path, | ||
| 131 | git_repo, | ||
| 132 | }) | ||
| 133 | } | ||
| 134 | |||
| 126 | pub fn initial_commit(&self) -> Result<Oid> { | 135 | pub fn initial_commit(&self) -> Result<Oid> { |
| 127 | let oid = self.git_repo.index()?.write_tree()?; | 136 | let oid = self.git_repo.index()?.write_tree()?; |
| 128 | let tree = self.git_repo.find_tree(oid)?; | 137 | let tree = self.git_repo.find_tree(oid)?; |