|
1 | | -use crate::{repo, Result}; |
2 | | -use anyhow::anyhow; |
3 | | -use git_repository::{bstr::ByteSlice, RepositoryState}; |
| 1 | +use crate::{named_repo, Result}; |
| 2 | +use git_repository::RepositoryState; |
4 | 3 |
|
5 | | -// Can we identify that a cherry pick operation is in progress |
6 | 4 | #[test] |
7 | 5 | fn cherry_pick() -> Result { |
8 | | - let repo = repo("make_cherry_pick_repo.sh").map(|r| r.to_thread_local())?; |
| 6 | + let repo = named_repo("make_cherry_pick_repo.sh")?; |
9 | 7 |
|
10 | 8 | let head = repo.head()?; |
11 | | - let head_name = head |
12 | | - .referent_name() |
13 | | - .ok_or_else(|| anyhow!("detached head?"))? |
14 | | - .shorten() |
15 | | - .to_str()?; |
16 | | - assert_eq!("master", head_name); |
17 | | - |
18 | | - assert_eq!(Some(RepositoryState::CherryPick), repo.in_progress_operation()); |
| 9 | + let head_name = head.referent_name().expect("no detached head").shorten(); |
| 10 | + assert_eq!(head_name, "main"); |
19 | 11 |
|
| 12 | + assert_eq!(repo.in_progress_operation(), Some(RepositoryState::CherryPick)); |
20 | 13 | Ok(()) |
21 | 14 | } |
22 | 15 |
|
23 | | -// Can we identify that we're in the middle of an interactive rebase? |
24 | 16 | #[test] |
25 | 17 | fn rebase_interactive() -> Result { |
26 | | - let repo = repo("make_rebase_i_repo.sh").map(|r| r.to_thread_local())?; |
| 18 | + let repo = named_repo("make_rebase_i_repo.sh")?; |
27 | 19 |
|
28 | 20 | let head = repo.head()?; |
29 | | - // TODO: Get rebase head/target |
30 | | - let head_name = head.referent_name(); |
31 | | - assert!(head_name.is_none()); |
32 | | - |
33 | | - assert_eq!(Some(RepositoryState::RebaseInteractive), repo.in_progress_operation()); |
| 21 | + assert!(head.is_detached()); |
| 22 | + assert_eq!(repo.in_progress_operation(), Some(RepositoryState::RebaseInteractive)); |
34 | 23 |
|
35 | 24 | Ok(()) |
36 | 25 | } |
37 | 26 |
|
38 | | -// Can we identify a revert operation when we see it? |
39 | 27 | #[test] |
40 | 28 | fn revert() -> Result { |
41 | | - let repo = repo("make_revert_repo.sh").map(|r| r.to_thread_local())?; |
| 29 | + let repo = named_repo("make_revert_repo.sh")?; |
42 | 30 |
|
43 | 31 | let head = repo.head()?; |
44 | | - let head_name = head |
45 | | - .referent_name() |
46 | | - .ok_or_else(|| anyhow!("detached head?"))? |
47 | | - .shorten() |
48 | | - .to_str()?; |
49 | | - assert_eq!("master", head_name); |
| 32 | + let head_name = head.referent_name().expect("no detached head").shorten(); |
| 33 | + assert_eq!(head_name, "main"); |
50 | 34 |
|
51 | 35 | assert_eq!(Some(RepositoryState::Revert), repo.in_progress_operation()); |
52 | 36 |
|
|
0 commit comments