Debian Codegraph @

src/lossy.rs

raw symbols SCIP
1 //! A library for parsing and generating Debian patch headers.
2 //!
3 //! # Examples
4 //!
5 //! ```rust
6 //! use dep3::lossy::PatchHeader;
7 //! use std::str::FromStr;
8 //! let text = r#"From: John Doe <john.doe@example>
9 //! Date: Mon, 1 Jan 2000 00:00:00 +0000
10 //! Subject: [PATCH] fix a bug
11 //! Bug-Debian: https://bugs.debian.org/123456
12 //! Bug: https://bugzilla.example.com/bug.cgi?id=123456
13 //! Forwarded: not-needed
14 //! "#;
15 //!
16 //! let patch_header = PatchHeader::from_str(text).unwrap();
17 //! assert_eq!(patch_header.description, Some("[PATCH] fix a bug".to_string()));
18 //! assert_eq!(patch_header.bug_debian, Some("https://bugs.debian.org/123456".parse().unwrap()));
19 //! ```
20 use craterust-analyzer cargo dep3 0.2.4 crate/::fieldsrust-analyzer cargo dep3 0.2.4 fields/::*;
21 use deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::{FromDeb822rust-analyzer cargo deb822-derive 0.3.1 FromDeb822:, FromDeb822Paragraphrust-analyzer cargo deb822-fast 0.2.3 convert/FromDeb822Paragraph#, Paragraphrust-analyzer cargo deb822-fast 0.2.3 Paragraph#, ToDeb822rust-analyzer cargo deb822-derive 0.3.1 ToDeb822:, ToDeb822Paragraphrust-analyzer cargo deb822-fast 0.2.3 convert/ToDeb822Paragraph#};
22
23 fn deserialize_daterust-analyzer cargo dep3 0.2.4 lossy/deserialize_date().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
24 chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#::parse_from_strrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]parse_from_str().(s, "%Y-%m-%d").map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
25 }
26
27 fn serialize_daterust-analyzer cargo dep3 0.2.4 lossy/serialize_date().(date: &chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
28 date.formatrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]format().("%Y-%m-%d").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
29 }
30
31 fn deserialize_originrust-analyzer cargo dep3 0.2.4 lossy/deserialize_origin().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#>, Originrust-analyzer cargo dep3 0.2.4 fields/Origin#), Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
32 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(craterust-analyzer cargo dep3 0.2.4 crate/::fieldsrust-analyzer cargo dep3 0.2.4 fields/::parse_originrust-analyzer cargo dep3 0.2.4 fields/parse_origin().(s))
33 }
34
35 fn serialize_originrust-analyzer cargo dep3 0.2.4 lossy/serialize_origin().((category, origin): &(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#>, Originrust-analyzer cargo dep3 0.2.4 fields/Origin#)) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
36 craterust-analyzer cargo dep3 0.2.4 crate/::fieldsrust-analyzer cargo dep3 0.2.4 fields/::format_originrust-analyzer cargo dep3 0.2.4 fields/format_origin().(category, origin)
37 }
38
39 /// A patch header.
40 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, FromDeb822rust-analyzer cargo deb822-derive 0.3.1 FromDeb822:, ToDeb822rust-analyzer cargo deb822-derive 0.3.1 ToDeb822:)]
41 pub struct PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# {
42 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Origin", serialize_with = serialize_originrust-analyzer cargo dep3 0.2.4 lossy/serialize_origin()., deserialize_with = deserialize_originrust-analyzer cargo dep3 0.2.4 lossy/deserialize_origin().)]
43 /// The origin of the patch.
44 pub originrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#origin.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#>, Originrust-analyzer cargo dep3 0.2.4 fields/Origin#)>,
45
46 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Forwarded")]
47 /// Whether the patch has been forwarded upstream.
48 pub forwardedrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#forwarded.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#>,
49
50 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Author")]
51 /// The author of the patch.
52 pub authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
53
54 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Reviewed-by")]
55 /// The person who reviewed the patch.
56 pub reviewed_byrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#reviewed_by.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
57
58 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Bug-Debian")]
59 /// The URL of the Debian bug report.
60 pub bug_debianrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#bug_debian.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#>,
61
62 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Last-Update", deserialize_with = deserialize_daterust-analyzer cargo dep3 0.2.4 lossy/deserialize_date()., serialize_with = serialize_daterust-analyzer cargo dep3 0.2.4 lossy/serialize_date().)]
63 /// The date of the last update.
64 pub last_updaterust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#last_update.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#>,
65
66 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Applied-Upstream")]
67 /// Whether the patch has been applied upstream.
68 pub applied_upstreamrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#applied_upstream.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#>,
69
70 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Bug")]
71 /// The URL of the upstream bug report.
72 pub bugrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#bug.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<urlrust-analyzer cargo url 2.5.8 crate/::Urlrust-analyzer cargo url 2.5.8 Url#>,
73
74 #[deb822rust-analyzer cargo deb822-derive 0.3.1 deb822:(field = "Description")]
75 /// The description of the patch.
76 pub descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
77 }
78
79 impl PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# {
80 /// Create a new patch header.
81 pub fn vendor_bugsrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]vendor_bugs().(&self, vendor: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
82 match vendor {
83 "Debian" => self.bug_debianrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#bug_debian..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|u| u.as_strrust-analyzer cargo url 2.5.8 impl#[Url]as_str().()),
84 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
85 }
86 }
87
88 /// The patch synopsis: the first line of the `Description` (or `Subject`)
89 /// field. Per DEP-3 the field carries a one-line synopsis optionally followed
90 /// by a longer description; this returns just the synopsis.
91 pub fn synopsisrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]synopsis().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
92 self.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description.
93 .as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()
94 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|d| d.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('\n').nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(d).trim_endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end().())
95 }
96
97 /// The long description: everything after the synopsis line of the
98 /// `Description` (or `Subject`) field, or `None` when there is only a
99 /// synopsis.
100 ///
101 /// A lone `.` line (the deb822 blank-line marker) is decoded back to an empty
102 /// line, so paragraph breaks read naturally.
103 pub fn long_descriptionrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]long_description().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
104 let rest = self.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('\n').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|x| x.1)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
105 let trimmed = rest.trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().('\n');
106 if trimmed.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
107 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
108 }
109 let decoded = trimmed
110 .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('\n')
111 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|line| if line rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."." { "" } else { line })
112 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
113 .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("\n");
114 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(decoded)
115 }
116 }
117
118 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# {
119 fn fmtrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
120 let paragraph: deb822_fastrust-analyzer cargo deb822-fast 0.2.3 crate/::Paragraphrust-analyzer cargo deb822-fast 0.2.3 Paragraph# = self.to_paragraphrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][`ToDeb822Paragraph<P>`]to_paragraph().();
121 paragraph.fmtrust-analyzer cargo deb822-fast 0.2.3 impl#[Paragraph][Display]fmt().(f)
122 }
123 }
124
125 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# {
126 type Errrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][FromStr]Err# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
127
128 fn from_strrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][FromStr], Selfrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
129 let paragraph = Paragraphrust-analyzer cargo deb822-fast 0.2.3 Paragraph#::from_strrust-analyzer cargo deb822-fast 0.2.3 impl#[Paragraph][FromStr]from_str().(s).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
130 let mut header = PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#::from_paragraphrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader][`FromDeb822Paragraph<P>`]from_paragraph().(&paragraph)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
131 if header.authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
132 header.authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author. = paragraph.getrust-analyzer cargo deb822-fast 0.2.3 impl#[Paragraph]get().("From").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().);
133 }
134 if header.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
135 header.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description. = paragraph.getrust-analyzer cargo deb822-fast 0.2.3 impl#[Paragraph]get().("Subject").maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().);
136 }
137 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(header)
138 }
139 }
140
141 #[cfg(test)]
142 mod testsrust-analyzer cargo dep3 0.2.4 lossy/tests/ {
143 use superrust-analyzer cargo dep3 0.2.4 lossy/::PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#;
144 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#;
145
146 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
147 fn test_upstreamrust-analyzer cargo dep3 0.2.4 lossy/tests/test_upstream().() {
148 let text = r#"From: Ulrich Drepper <[email protected]>
149 Subject: Fix regex problems with some multi-bytes characters
150
151 * posix/bug-regex17.c: Add testcases.
152 * posix/regcomp.c (re_compile_fastmap_iter): Rewrite COMPLEX_BRACKET
153 handling.
154
155 Origin: upstream, http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=bdb56bac
156 Bug: http://sourceware.org/bugzilla/show_bug.cgi?id=9697
157 Bug-Debian: http://bugs.debian.org/510219
158 "#;
159
160 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
161
162 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
163 header.originrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#origin.,
164 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
165 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo dep3 0.2.4 lossy/::OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Upstreamrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Upstream#),
166 superrust-analyzer cargo dep3 0.2.4 lossy/::Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Otherrust-analyzer cargo dep3 0.2.4 fields/Origin#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(
167 "http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=bdb56bac"
168 ))
169 ))
170 );
171 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.forwardedrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#forwarded., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
172 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
173 header.authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author.,
174 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Ulrich Drepper <[email protected]>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
175 );
176 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.reviewed_byrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#reviewed_by., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
177 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.last_updaterust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#last_update., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
178 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.applied_upstreamrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#applied_upstream., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
180 header.bugrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#bug.,
181 "http://sourceware.org/bugzilla/show_bug.cgi?id=9697"
182 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
183 .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
184 );
185 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
186 header.bug_debianrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#bug_debian.,
187 "http://bugs.debian.org/510219".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
188 );
189 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
190 header.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description.,
191 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Fix regex problems with some multi-bytes characters\n\n* posix/bug-regex17.c: Add testcases.\n* posix/regcomp.c (re_compile_fastmap_iter): Rewrite COMPLEX_BRACKET\nhandling.\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
192 );
193 }
194
195 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
196 fn test_forwardedrust-analyzer cargo dep3 0.2.4 lossy/tests/test_forwarded().() {
197 let text = r#"Description: Use FHS compliant paths by default
198 Upstream is not interested in switching to those paths.
199 .
200 But we will continue using them in Debian nevertheless to comply with
201 our policy.
202 Forwarded: http://lists.example.com/oct-2006/1234.html
203 Author: John Doe <[email protected]>
204 Last-Update: 2006-12-21
205 "#;
206 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
207
208 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.originrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#origin., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
209 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
210 header.forwardedrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#forwarded.,
211 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo dep3 0.2.4 lossy/::Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Yesrust-analyzer cargo dep3 0.2.4 fields/Forwarded#Yes#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(
212 "http://lists.example.com/oct-2006/1234.html"
213 )))
214 );
215 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
216 header.authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author.,
217 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("John Doe <[email protected]>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
218 );
219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.reviewed_byrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#reviewed_by., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
220 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
221 header.last_updaterust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#last_update.,
222 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]from_ymd_opt().(2006, 12, 21).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())
223 );
224 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.applied_upstreamrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#applied_upstream., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
225 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
226 header.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description.,
227 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Use FHS compliant paths by default\nUpstream is not interested in switching to those paths.\n.\nBut we will continue using them in Debian nevertheless to comply with\nour policy.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
228 );
229 }
230
231 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
232 fn test_synopsis_and_long_descriptionrust-analyzer cargo dep3 0.2.4 lossy/tests/test_synopsis_and_long_description().() {
233 let text = r#"Description: Use FHS compliant paths by default
234 Upstream is not interested in switching to those paths.
235 .
236 But we will continue using them in Debian nevertheless.
237 Author: John Doe <[email protected]>
238 "#;
239 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
240 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
241 header.synopsisrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]synopsis().(),
242 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Use FHS compliant paths by default")
243 );
244 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
245 header.long_descriptionrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]long_description().().as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(),
246 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
247 "Upstream is not interested in switching to those paths.\n\nBut we will continue using them in Debian nevertheless."
248 )
249 );
250 }
251
252 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
253 fn test_synopsis_only_has_no_long_descriptionrust-analyzer cargo dep3 0.2.4 lossy/tests/test_synopsis_only_has_no_long_description().() {
254 let text = "Description: A one-line synopsis only\nAuthor: X <[email protected]>\n";
255 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
256 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.synopsisrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]synopsis().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("A one-line synopsis only"));
257 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.long_descriptionrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]long_description().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
258 }
259
260 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
261 fn test_synopsis_from_subjectrust-analyzer cargo dep3 0.2.4 lossy/tests/test_synopsis_from_subject().() {
262 // The git-style `Subject` aliases `Description`, so synopsis works too.
263 let text = "Subject: Fix the thing\n Details here.\nFrom: X <[email protected]>\n";
264 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
265 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.synopsisrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]synopsis().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Fix the thing"));
266 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.long_descriptionrust-analyzer cargo dep3 0.2.4 lossy/impl#[PatchHeader]long_description().().as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Details here."));
267 }
268
269 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
270 fn test_not_forwardedrust-analyzer cargo dep3 0.2.4 lossy/tests/test_not_forwarded().() {
271 let text = r#"Description: Workaround for broken symbol resolving on mips/mipsel
272 The correct fix will be done in etch and it will require toolchain
273 fixes.
274 Forwarded: not-needed
275 Origin: vendor, http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=80;bug=265678
276 Bug-Debian: http://bugs.debian.org/265678
277 Author: Thiemo Seufer <[email protected]>
278 "#;
279
280 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
281
282 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
283 header.originrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#origin.,
284 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
285 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo dep3 0.2.4 lossy/::OriginCategoryrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#::Vendorrust-analyzer cargo dep3 0.2.4 fields/OriginCategory#Vendor#),
286 superrust-analyzer cargo dep3 0.2.4 lossy/::Originrust-analyzer cargo dep3 0.2.4 fields/Origin#::Otherrust-analyzer cargo dep3 0.2.4 fields/Origin#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(
287 "http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=80;bug=265678"
288 ))
289 ))
290 );
291 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.forwardedrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#forwarded., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo dep3 0.2.4 lossy/::Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::NotNeededrust-analyzer cargo dep3 0.2.4 fields/Forwarded#NotNeeded#));
292 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
293 header.authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author.,
294 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Thiemo Seufer <[email protected]>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
295 );
296 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.reviewed_byrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#reviewed_by., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
297 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.last_updaterust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#last_update., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
298 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.applied_upstreamrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#applied_upstream., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
299 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
300 header.bug_debianrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#bug_debian.,
301 "http://bugs.debian.org/265678".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
302 );
303
304 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
305 header.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description.,
306 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(
307 "Workaround for broken symbol resolving on mips/mipsel
308 The correct fix will be done in etch and it will require toolchain
309 fixes."
310 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
311 )
312 );
313 }
314
315 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
316 fn test_applied_upstreamrust-analyzer cargo dep3 0.2.4 lossy/tests/test_applied_upstream().() {
317 let text = r#"Description: Fix widget frobnication speeds
318 Frobnicating widgets too quickly tended to cause explosions.
319 Forwarded: http://lists.example.com/2010/03/1234.html
320 Author: John Doe <[email protected]>
321 Applied-Upstream: 1.2, http://bzr.example.com/frobnicator/trunk/revision/123
322 Last-Update: 2010-03-29
323 "#;
324 let header: PatchHeaderrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader# = text.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
325
326 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.originrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#origin., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
327 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
328 header.forwardedrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#forwarded.,
329 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo dep3 0.2.4 lossy/::Forwardedrust-analyzer cargo dep3 0.2.4 fields/Forwarded#::Yesrust-analyzer cargo dep3 0.2.4 fields/Forwarded#Yes#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(
330 "http://lists.example.com/2010/03/1234.html"
331 )))
332 );
333 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
334 header.authorrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#author.,
335 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("John Doe <[email protected]>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
336 );
337 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(header.reviewed_byrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#reviewed_by., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
338 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
339 header.last_updaterust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#last_update.,
340 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]from_ymd_opt().(2010, 3, 29).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())
341 );
342 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
343 header.applied_upstreamrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#applied_upstream.,
344 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(superrust-analyzer cargo dep3 0.2.4 lossy/::AppliedUpstreamrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#::Otherrust-analyzer cargo dep3 0.2.4 fields/AppliedUpstream#Other#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(
345 "1.2, http://bzr.example.com/frobnicator/trunk/revision/123"
346 )))
347 );
348 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
349 header.descriptionrust-analyzer cargo dep3 0.2.4 lossy/PatchHeader#description.,
350 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("Fix widget frobnication speeds\nFrobnicating widgets too quickly tended to cause explosions.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
351 );
352 }
353 }