| @@ -21,32 +21,40 @@ mod update { · 20 unmodified lines |
| 21 | 21 | use git_ref::TargetRef; |
| 22 | 22 | |
| 23 | 23 | #[test] |
| 24 | | − #[ignore] |
| 25 | 24 | fn various_valid_updates() { |
| 26 | 25 | let repo = repo("two-origins"); |
| 27 | 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 | 29 | "refs/heads/main:refs/remotes/origin/main", |
| 31 | 30 | fetch::refs::update::Mode::NoChangeNeeded, |
| 31 | + true, |
| 32 | 32 | "these refs are en-par since the initial clone", |
| 33 | 33 | ), |
| 34 | 34 | ( |
| 35 | 35 | "refs/heads/main", |
| 36 | 36 | fetch::refs::update::Mode::NoChangeNeeded, |
| 37 | + false, |
| 37 | 38 | "without local destination ref there is nothing to do for us, ever (except for FETCH_HEADs) later", |
| 38 | 39 | ), |
| 39 | 40 | ( |
| 40 | 41 | "refs/heads/main:refs/remotes/origin/new-main", |
| 41 | 42 | fetch::refs::update::Mode::New, |
| 43 | + true, |
| 42 | 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 | 48 | fetch::refs::update::Mode::Forced, |
| 49 | + true, |
| 47 | 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 | 59 | let (mapping, specs) = mapping_from_spec(spec, &repo); |
| 52 | 60 | let out = fetch::refs::update(&repo, &mapping, &specs, fetch::DryRun::Yes).unwrap(); |
| @@ -55,12 +63,12 @@ mod update { · 2 unmodified lines |
| 55 | 63 | out.updates, |
| 56 | 64 | vec![fetch::refs::Update { |
| 57 | 65 | mode: expected_mode, |
| 58 | | − edit_index: Some(0), |
| 66 | + edit_index: has_edit_index.then(|| 0), |
| 59 | 67 | spec_index: 0 |
| 60 | 68 | }], |
| 61 | 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 | |