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

Function test_fetch_changes_with_commits

src/git.rs:1346–1397  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1344
1345 #[tokio::test]
1346 async fn test_fetch_changes_with_commits() {
1347 let ctx = AppContext::builder().build();
1348
1349 // Create main repository
1350 let main_repo = TestGitRepository::new().unwrap();
1351 main_repo.init_with_main_branch().unwrap();
1352
1353 // Create task repository (simulating a copied repository)
1354 let task_repo = TestGitRepository::new().unwrap();
1355 task_repo.clone_from(&main_repo).unwrap();
1356
1357 // Create a branch in task repo with new commits
1358 let branch_name = "tsk/test/test-task/efgh5678";
1359 task_repo.checkout_new_branch(branch_name).unwrap();
1360
1361 // Capture source_commit before adding new commits
1362 let source_commit = task_repo.get_current_commit().unwrap();
1363
1364 // Add a new commit
1365 task_repo
1366 .create_file("new_feature.rs", "fn new_feature() {}")
1367 .unwrap();
1368 task_repo.stage_all().unwrap();
1369 task_repo.commit("Add new feature").unwrap();
1370
1371 let manager = RepoManager::new(&ctx);
1372
1373 // Fetch changes from task repo to main repo (should return true as there are new commits)
1374 let result = manager
1375 .fetch_changes(
1376 task_repo.path(),
1377 branch_name,
1378 main_repo.path(),
1379 &source_commit,
1380 Some("main"),
1381 false,
1382 )
1383 .await;
1384
1385 assert!(result.is_ok(), "Error: {result:?}");
1386 assert!(
1387 result.unwrap().has_changes,
1388 "Should return true when new commits exist"
1389 );
1390
1391 // Verify the branch exists in main repo
1392 let main_branches = main_repo.branches().unwrap();
1393 assert!(
1394 main_branches.contains(&branch_name.to_string()),
1395 "Branch should exist after fetch"
1396 );
1397 }
1398
1399 #[tokio::test]
1400 async fn test_fetch_changes_with_git_town_enabled() {

Callers

nothing calls this directly

Calls 11

init_with_main_branchMethod · 0.80
clone_fromMethod · 0.80
checkout_new_branchMethod · 0.80
get_current_commitMethod · 0.80
create_fileMethod · 0.80
stage_allMethod · 0.80
commitMethod · 0.80
fetch_changesMethod · 0.80
pathMethod · 0.80
branchesMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected