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

Function test_copy_repo_with_source_commit

src/git.rs:1475–1541  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1473
1474 #[tokio::test]
1475 async fn test_copy_repo_with_source_commit() {
1476 let ctx = AppContext::builder().build();
1477
1478 // Create a repository with multiple commits
1479 let test_repo = TestGitRepository::new().unwrap();
1480 let first_commit = test_repo.init_with_commit().unwrap();
1481
1482 // Add more commits
1483 test_repo
1484 .create_file("feature1.rs", "fn feature1() {}")
1485 .unwrap();
1486 test_repo.stage_all().unwrap();
1487 test_repo.commit("Add feature1").unwrap();
1488
1489 test_repo
1490 .create_file("feature2.rs", "fn feature2() {}")
1491 .unwrap();
1492 test_repo.stage_all().unwrap();
1493 let _latest_commit = test_repo.commit("Add feature2").unwrap();
1494
1495 let manager = RepoManager::new(&ctx);
1496
1497 // Copy repo from the first commit
1498 let task_id = "efgh5678";
1499 let branch_name = "tsk/test/copy-repo-test/efgh5678";
1500 let result = manager
1501 .copy_repo(
1502 task_id,
1503 test_repo.path(),
1504 Some(&first_commit),
1505 branch_name,
1506 CopyMode::WorkingTree,
1507 )
1508 .await;
1509
1510 assert!(result.is_ok());
1511 let copied_path = result.unwrap().repo_path;
1512
1513 assert!(copied_path.exists());
1514
1515 // Verify the working directory contains all current files (preserving working directory state)
1516 // even though the branch was created from the first commit
1517 assert!(
1518 copied_path.join("feature1.rs").exists(),
1519 "Working directory files should be preserved"
1520 );
1521 assert!(
1522 copied_path.join("feature2.rs").exists(),
1523 "Working directory files should be preserved"
1524 );
1525 assert!(
1526 copied_path.join("README.md").exists(),
1527 "Original files should be preserved"
1528 );
1529
1530 // Verify the branch was created from the first commit by checking git history
1531 let copied_repo = TestGitRepository::new().unwrap();
1532 let _ = std::fs::remove_dir_all(copied_repo.path());

Callers

nothing calls this directly

Calls 8

init_with_commitMethod · 0.80
create_fileMethod · 0.80
stage_allMethod · 0.80
commitMethod · 0.80
copy_repoMethod · 0.80
pathMethod · 0.80
get_head_commitMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected