From 9de586fcf5b6e5bc0ed006fb868a0673ba1ac038 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Sat, 22 Apr 2023 17:20:03 +0200 Subject: [PATCH] chore: rename author to name --- src/rpm/builder.rs | 24 ++++++++++++++---------- src/rpm/headers/header.rs | 2 +- src/rpm/package.rs | 26 ++++++++++++-------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/rpm/builder.rs b/src/rpm/builder.rs index c091404c..daf49aba 100644 --- a/src/rpm/builder.rs +++ b/src/rpm/builder.rs @@ -111,7 +111,9 @@ pub struct RPMBuilder { pre_uninst_script: Option, post_uninst_script: Option, - changelog_authors: Vec, + /// The author name with email followed by a dash with the version + /// `Max Mustermann - 0.1-1` + changelog_names: Vec, changelog_entries: Vec, changelog_times: Vec>, compressor: Compressor, @@ -201,35 +203,37 @@ impl RPMBuilder { self } - /// Add an entry to the changelog, compromised of author, description, and the date and time of the change. + /// Add an entry to the changelog, compromised of changelog name (which includes author, email followed by + /// a dash followed by a version number), + /// description, and the date and time of the change. /// /// ```ignore /// let pkg = rpm::RPMBuilder::new(..) /// .add_changelog_entry( - /// "Alfred J. Quack ", + /// "Alfred J. Quack - 0.1-27", /// r#" - Obsolete `fn foo`, in favor of `fn bar`. /// - Secondly."#, /// rpm::chrono::Utc.timestamp_opt(1681411811, 0).unwrap(), /// ) /// .add_changelog_entry( - /// "Gambl B. Xen ", + /// "Gambl B. Xen - 0.1-26", /// " - Add enumerator." /// rpm::chrono::DateTime::parse_from_rfc3339("1996-12-19T16:39:57-08:00").unwrap(), /// ) /// //.. /// ``` - pub fn add_changelog_entry( + pub fn add_changelog_entry( mut self, - author: A, + name: N, entry: E, datetime: chrono::DateTime, ) -> Self where - A: AsRef, + N: AsRef, E: AsRef, TZ: chrono::TimeZone, { - self.changelog_authors.push(author.as_ref().to_owned()); + self.changelog_names.push(name.as_ref().to_owned()); self.changelog_entries.push(entry.as_ref().to_owned()); self.changelog_times .push(datetime.with_timezone(&chrono::Utc)); @@ -1001,11 +1005,11 @@ impl RPMBuilder { )); } - if !self.changelog_authors.is_empty() { + if !self.changelog_names.is_empty() { actual_records.push(IndexEntry::new( IndexTag::RPMTAG_CHANGELOGNAME, offset, - IndexData::StringArray(self.changelog_authors), + IndexData::StringArray(self.changelog_names), )); actual_records.push(IndexEntry::new( IndexTag::RPMTAG_CHANGELOGTEXT, diff --git a/src/rpm/headers/header.rs b/src/rpm/headers/header.rs index 578be65d..7b83eee4 100644 --- a/src/rpm/headers/header.rs +++ b/src/rpm/headers/header.rs @@ -469,7 +469,7 @@ impl FileDigest { /// User facing accessor type for a changelog entry #[derive(Debug, Clone, Hash, Eq, PartialEq)] pub struct ChangelogEntry { - pub author: String, + pub name: String, pub timestamp: u64, pub description: String, } diff --git a/src/rpm/package.rs b/src/rpm/package.rs index b79749ec..05d6cf5c 100644 --- a/src/rpm/package.rs +++ b/src/rpm/package.rs @@ -782,7 +782,7 @@ impl RPMPackageMetadata { /// Return a list of changelog entries pub fn get_changelog_entries(&self) -> Result, RPMError> { - let authors = self + let names = self .header .get_entry_data_as_string_array(IndexTag::RPMTAG_CHANGELOGNAME); let timestamps = self @@ -793,26 +793,24 @@ impl RPMPackageMetadata { .get_entry_data_as_string_array(IndexTag::RPMTAG_CHANGELOGTEXT); // Return an empty list if the tags are not present - match (authors, timestamps, descriptions) { + match (names, timestamps, descriptions) { ( Err(RPMError::TagNotFound(_)), Err(RPMError::TagNotFound(_)), Err(RPMError::TagNotFound(_)), ) => Ok(vec![]), - (Ok(authors), Ok(timestamps), Ok(descriptions)) => { - let v = Vec::from_iter( - itertools::multizip((authors, timestamps, descriptions)).map( - |(author, timestamp, description)| ChangelogEntry { - author: author.to_owned(), - timestamp: timestamp as u64, - description: description.to_owned(), - }, - ), - ); + (Ok(names), Ok(timestamps), Ok(descriptions)) => { + let v = Vec::from_iter(itertools::multizip((names, timestamps, descriptions)).map( + |(name, timestamp, description)| ChangelogEntry { + name: name.to_owned(), + timestamp: timestamp as u64, + description: description.to_owned(), + }, + )); Ok(v) } - (author, timestamp, description) => { - author?; + (name, timestamp, description) => { + name?; timestamp?; description?; unreachable!()