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

Function test_create_branch_from_commit

src/git_operations.rs:710–742  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

708
709 #[tokio::test]
710 async fn test_create_branch_from_commit() {
711 let test_repo = TestGitRepository::new().unwrap();
712 test_repo.init_with_commit().unwrap();
713 let repo_path = test_repo.path();
714
715 // Create first commit (beyond the initial one)
716 test_repo.create_file("file1.txt", "First file").unwrap();
717 test_repo.stage_all().unwrap();
718 test_repo.commit("First commit").unwrap();
719 let first_commit_sha = get_current_commit(repo_path).await.unwrap();
720
721 // Create second commit
722 test_repo.create_file("file2.txt", "Second file").unwrap();
723 test_repo.stage_all().unwrap();
724 test_repo.commit("Second commit").unwrap();
725
726 // Create a branch from the first commit
727 create_branch_from_commit(repo_path, "feature-from-first", &first_commit_sha)
728 .await
729 .unwrap();
730
731 // Verify we're on the new branch
732 let branch = test_repo.current_branch().unwrap();
733 assert_eq!(branch, "feature-from-first");
734
735 // Verify the branch is at the first commit
736 let current_sha = get_current_commit(repo_path).await.unwrap();
737 assert_eq!(current_sha, first_commit_sha);
738
739 // Verify the second file doesn't exist in the working directory
740 assert!(!repo_path.join("file2.txt").exists());
741 assert!(repo_path.join("file1.txt").exists());
742 }
743
744 #[tokio::test]
745 async fn test_get_current_commit_empty_repository() {

Callers

nothing calls this directly

Calls 8

get_current_commitFunction · 0.85
init_with_commitMethod · 0.80
pathMethod · 0.80
create_fileMethod · 0.80
stage_allMethod · 0.80
commitMethod · 0.80
current_branchMethod · 0.80

Tested by

no test coverage detected