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

Function test_fetch_changes_no_commits

src/git.rs:1298–1343  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1296
1297 #[tokio::test]
1298 async fn test_fetch_changes_no_commits() {
1299 let ctx = AppContext::builder().build();
1300
1301 // Create main repository
1302 let main_repo = TestGitRepository::new().unwrap();
1303 main_repo.init_with_main_branch().unwrap();
1304
1305 // Create task repository (simulating a copied repository)
1306 let task_repo = TestGitRepository::new().unwrap();
1307 task_repo.clone_from(&main_repo).unwrap();
1308
1309 // Create a branch in task repo with no new commits
1310 let branch_name = "tsk/test/test-task/abcd1234";
1311 task_repo.checkout_new_branch(branch_name).unwrap();
1312
1313 // Don't add any new commits - just the branch
1314 // The source_commit is the current HEAD (same as before creating the branch)
1315 let source_commit = task_repo.get_current_commit().unwrap();
1316
1317 let manager = RepoManager::new(&ctx);
1318
1319 // Fetch changes from task repo to main repo (should return false as there are no new commits)
1320 let result = manager
1321 .fetch_changes(
1322 task_repo.path(),
1323 branch_name,
1324 main_repo.path(),
1325 &source_commit,
1326 Some("main"),
1327 false,
1328 )
1329 .await;
1330
1331 assert!(result.is_ok(), "Error: {result:?}");
1332 assert!(
1333 !result.unwrap().has_changes,
1334 "Should return false when no new commits"
1335 );
1336
1337 // Verify the branch was cleaned up in main repo
1338 let main_branches = main_repo.branches().unwrap();
1339 assert!(
1340 !main_branches.contains(&branch_name.to_string()),
1341 "Branch should be cleaned up when no commits"
1342 );
1343 }
1344
1345 #[tokio::test]
1346 async fn test_fetch_changes_with_commits() {

Callers

nothing calls this directly

Calls 8

init_with_main_branchMethod · 0.80
clone_fromMethod · 0.80
checkout_new_branchMethod · 0.80
get_current_commitMethod · 0.80
fetch_changesMethod · 0.80
pathMethod · 0.80
branchesMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected