MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / clone_from

Method clone_from

src/test_utils/git_test_utils.rs:279–294  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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<()> {

Calls 5

initMethod · 0.80
run_git_commandMethod · 0.80
pathMethod · 0.80
current_branchMethod · 0.80
get_current_commitMethod · 0.80

Tested by

no test coverage detected