Set up this repo as a task clone of another repo, tracking its current branch. Initializes, adds the source as origin, fetches, and checks out its current branch. Returns the current commit SHA.
(&self, source: &TestGitRepository)
| 277 | /// Initializes, adds the source as origin, fetches, and checks out its current branch. |
| 278 | /// Returns the current commit SHA. |
| 279 | pub fn clone_from(&self, source: &TestGitRepository) -> Result<String> { |
| 280 | self.init()?; |
| 281 | self.run_git_command(&[ |
| 282 | "remote", |
| 283 | "add", |
| 284 | "origin", |
| 285 | source |
| 286 | .path() |
| 287 | .to_str() |
| 288 | .ok_or_else(|| anyhow::anyhow!("Invalid source path"))?, |
| 289 | ])?; |
| 290 | self.run_git_command(&["fetch", "origin"])?; |
| 291 | let branch = source.current_branch()?; |
| 292 | self.run_git_command(&["checkout", "-b", &branch, &format!("origin/{branch}")])?; |
| 293 | self.get_current_commit() |
| 294 | } |
| 295 | |
| 296 | /// Add another repository as a git submodule at the given path. |
| 297 | pub fn add_submodule(&self, source: &TestGitRepository, path: &str) -> Result<()> { |
no test coverage detected