| @@ -1,12 +1,32 @@ |
| 1 | use crate::spec::parse::{parse, try_parse_opts, Options, PrefixHintOwned}; | 1 | use crate::spec::parse::{parse, try_parse_opts, Options, PrefixHintOwned}; |
| 2 | | 2 | |
| | 3 | fn anchor_hint() -> Option<PrefixHintOwned> { |
| | 4 | Some(PrefixHintOwned::DescribeAnchor { |
| | 5 | ref_name: "cargo-smart-release".into(), |
| | 6 | generation: 679, |
| | 7 | }) |
| | 8 | } |
| | 9 | |
| 3 | #[test] | 10 | #[test] |
| 4 | fn full_format_parses_hash_portion_as_prefix() { | 11 | fn full_format_parses_hash_portion_as_prefix() { |
| 5 | let rec = parse("cargo-smart-release-679-g3bee7fb"); | 12 | let rec = parse("cargo-smart-release-679-g3bee7fb"); |
| 6 | assert!(rec.kind.is_none()); | 13 | assert!(rec.kind.is_none()); |
| 7 | assert_eq!(rec.find_ref[0], None, "references are not resolved in describe output"); | 14 | assert_eq!(rec.find_ref[0], None, "references are not resolved in describe output"); |
| 8 | assert_eq!(rec.prefix[0], Some(git_hash::Prefix::from_hex("3bee7fb").unwrap())); | 15 | assert_eq!(rec.prefix[0], Some(git_hash::Prefix::from_hex("3bee7fb").unwrap())); |
| 9 | assert_eq!(rec.prefix_hint[0], Some(PrefixHintOwned::MustBeCommit)); | 16 | assert_eq!(rec.prefix_hint[0], anchor_hint()); |
| | 17 | assert_eq!(rec.calls, 1); |
| | 18 | |
| | 19 | let rec = parse("v1.0-0-g3bee7fb"); |
| | 20 | assert!(rec.kind.is_none()); |
| | 21 | assert_eq!(rec.find_ref[0], None, "references are not resolved in describe output"); |
| | 22 | assert_eq!(rec.prefix[0], Some(git_hash::Prefix::from_hex("3bee7fb").unwrap())); |
| | 23 | assert_eq!( |
| | 24 | rec.prefix_hint[0], |
| | 25 | Some(PrefixHintOwned::DescribeAnchor { |
| | 26 | ref_name: "v1.0".into(), |
| | 27 | generation: 0, |
| | 28 | }) |
| | 29 | ); |
| 10 | assert_eq!(rec.calls, 1); | 30 | assert_eq!(rec.calls, 1); |
| 11 | } | 31 | } |
| 12 | | 32 | |
| @@ -62,7 +82,7 @@ fn full_format_with_dirty_suffix_is_recognized() { · 49 unmodified lines |
| 62 | assert!(rec.kind.is_none()); | 82 | assert!(rec.kind.is_none()); |
| 63 | assert_eq!(rec.find_ref[0], None, "git does not see this as prefix, we do"); | 83 | assert_eq!(rec.find_ref[0], None, "git does not see this as prefix, we do"); |
| 64 | assert_eq!(rec.prefix[0], Some(git_hash::Prefix::from_hex("3bee7fb").unwrap()),); | 84 | assert_eq!(rec.prefix[0], Some(git_hash::Prefix::from_hex("3bee7fb").unwrap()),); |
| 65 | assert_eq!(rec.prefix_hint[0], Some(PrefixHintOwned::MustBeCommit)); | 85 | assert_eq!(rec.prefix_hint[0], anchor_hint()); |
| 66 | assert_eq!(rec.calls, 1); | 86 | assert_eq!(rec.calls, 1); |
| 67 | } | 87 | } |
| 68 | | 88 | |