| @@ -21,32 +21,40 @@ mod update { · 20 unmodified lines |
| 21 | use git_ref::TargetRef; | 21 | use git_ref::TargetRef; |
| 22 | | 22 | |
| 23 | #[test] | 23 | #[test] |
| 24 | #[ignore] | | |
| 25 | fn various_valid_updates() { | 24 | fn various_valid_updates() { |
| 26 | let repo = repo("two-origins"); | 25 | let repo = repo("two-origins"); |
| 27 | // TODO: test reflog message (various cases if it's new) | 26 | // TODO: test reflog message (various cases if it's new) |
| 28 | for (spec, expected_mode, detail) in [ | 27 | for (spec, expected_mode, has_edit_index, detail) in [ |
| 29 | ( | 28 | ( |
| 30 | "refs/heads/main:refs/remotes/origin/main", | 29 | "refs/heads/main:refs/remotes/origin/main", |
| 31 | fetch::refs::update::Mode::NoChangeNeeded, | 30 | fetch::refs::update::Mode::NoChangeNeeded, |
| | 31 | true, |
| 32 | "these refs are en-par since the initial clone", | 32 | "these refs are en-par since the initial clone", |
| 33 | ), | 33 | ), |
| 34 | ( | 34 | ( |
| 35 | "refs/heads/main", | 35 | "refs/heads/main", |
| 36 | fetch::refs::update::Mode::NoChangeNeeded, | 36 | fetch::refs::update::Mode::NoChangeNeeded, |
| | 37 | false, |
| 37 | "without local destination ref there is nothing to do for us, ever (except for FETCH_HEADs) later", | 38 | "without local destination ref there is nothing to do for us, ever (except for FETCH_HEADs) later", |
| 38 | ), | 39 | ), |
| 39 | ( | 40 | ( |
| 40 | "refs/heads/main:refs/remotes/origin/new-main", | 41 | "refs/heads/main:refs/remotes/origin/new-main", |
| 41 | fetch::refs::update::Mode::New, | 42 | fetch::refs::update::Mode::New, |
| | 43 | true, |
| 42 | "the destination branch doesn't exist and needs to be created", | 44 | "the destination branch doesn't exist and needs to be created", |
| 43 | ), | 45 | ), |
| 44 | ( | 46 | ( |
| 45 | "+refs/heads/main:refs/heads/g", | 47 | "+refs/heads/main:refs/remotes/origin/g", |
| 46 | fetch::refs::update::Mode::Forced, | 48 | fetch::refs::update::Mode::Forced, |
| | 49 | true, |
| 47 | "a forced non-fastforward (main goes backwards)", | 50 | "a forced non-fastforward (main goes backwards)", |
| 48 | ), | 51 | ), |
| 49 | // ("refs/heads/g:refs/heads/main", fetch::refs::update::Mode::FastForward, "a fast-forward only fast-forward situation, all good"), | 52 | // ( |
| | 53 | // "refs/remotes/origin/g:refs/heads/not-currently-checked-out", |
| | 54 | // fetch::refs::update::Mode::FastForward, |
| | 55 | // true, |
| | 56 | // "a fast-forward only fast-forward situation, all good", |
| | 57 | // ), |
| 50 | ] { | 58 | ] { |
| 51 | let (mapping, specs) = mapping_from_spec(spec, &repo); | 59 | let (mapping, specs) = mapping_from_spec(spec, &repo); |
| 52 | let out = fetch::refs::update(&repo, &mapping, &specs, fetch::DryRun::Yes).unwrap(); | 60 | let out = fetch::refs::update(&repo, &mapping, &specs, fetch::DryRun::Yes).unwrap(); |
| @@ -55,12 +63,12 @@ mod update { · 2 unmodified lines |
| 55 | out.updates, | 63 | out.updates, |
| 56 | vec![fetch::refs::Update { | 64 | vec![fetch::refs::Update { |
| 57 | mode: expected_mode, | 65 | mode: expected_mode, |
| 58 | edit_index: Some(0), | 66 | edit_index: has_edit_index.then(|| 0), |
| 59 | spec_index: 0 | 67 | spec_index: 0 |
| 60 | }], | 68 | }], |
| 61 | "{spec:?}: {detail}" | 69 | "{spec:?}: {detail}" |
| 62 | ); | 70 | ); |
| 63 | assert_eq!(out.edits.len(), 1); | 71 | assert_eq!(out.edits.len(), has_edit_index.then(|| 1).unwrap_or(0)); |
| 64 | } | 72 | } |
| 65 | } | 73 | } |
| 66 | | 74 | |