()
| 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() { |
nothing calls this directly
no test coverage detected