| @@ -8,27 +8,10 @@ use git_repository::{ · 7 unmodified lines |
| 8 | 8 | prelude::{CacheAccessExt, ObjectAccessExt, ReferenceAccessExt, ReferenceExt}, |
| 9 | 9 | }; |
| 10 | 10 | |
| 11 | +use crate::command::changelog_impl::{history, History}; |
| 11 | 12 | use crate::utils::{component_to_bytes, is_tag_name, is_tag_version, package_by_name, tag_prefix}; |
| 12 | 13 | use std::cell::RefCell; |
| 13 | 14 | |
| 14 | | −/// A head reference will all commits that are 'governed' by it, that is are in its exclusive ancestry. |
| 15 | | −pub struct Segment<'a> { |
| 16 | | − _head: git::refs::Reference, |
| 17 | | − /// only relevant history items, that is those that change code in the respective crate. |
| 18 | | − history: Vec<&'a HistoryItem>, |
| 19 | | −} |
| 20 | | − |
| 21 | | −pub struct History { |
| 22 | | − head: git::refs::Reference, |
| 23 | | − items: Vec<HistoryItem>, |
| 24 | | −} |
| 25 | | − |
| 26 | | −pub struct HistoryItem { |
| 27 | | − id: git::hash::ObjectId, |
| 28 | | − _message: git::bstr::BString, |
| 29 | | − tree_data: Vec<u8>, |
| 30 | | −} |
| 31 | | − |
| 32 | 15 | pub fn commit_history(repo: &git::Easy) -> anyhow::Result<Option<History>> { |
| 33 | 16 | let start = Instant::now(); |
| 34 | 17 | let prev = repo.object_cache_size(64 * 1024)?; |
| @@ -47,7 +30,7 @@ pub fn commit_history(repo: &git::Easy) -> anyhow::Result<Option<History>> { · 12 unmodified lines |
| 47 | 30 | (commit.message.to_owned(), commit.tree()) |
| 48 | 31 | }; |
| 49 | 32 | |
| 50 | | − items.push(HistoryItem { |
| 33 | + items.push(history::Item { |
| 51 | 34 | id: commit_id.detach(), |
| 52 | 35 | _message: message, |
| 53 | 36 | tree_data: repo.find_object(tree_id)?.data.to_owned(), |
| @@ -69,11 +52,11 @@ pub fn commit_history(repo: &git::Easy) -> anyhow::Result<Option<History>> { · 15 unmodified lines |
| 69 | 52 | } |
| 70 | 53 | |
| 71 | 54 | /// Return the head reference followed by all tags affecting `crate_name` as per our tag name rules, ordered by ancestry. |
| 72 | | −pub fn crate_references_descending<'h>( |
| 55 | +pub fn ref_segments<'h>( |
| 73 | 56 | crate_name: &str, |
| 74 | 57 | ctx: &crate::Context, |
| 75 | 58 | history: &'h History, |
| 76 | | −) -> anyhow::Result<Vec<Segment<'h>>> { |
| 59 | +) -> anyhow::Result<Vec<history::Segment<'h>>> { |
| 77 | 60 | let meta = &ctx.meta; |
| 78 | 61 | let package = package_by_name(meta, crate_name)?; |
| 79 | 62 | let tag_prefix = tag_prefix(package, &ctx.repo); |
| @@ -115,7 +98,7 @@ pub fn crate_references_descending<'h>( · 35 unmodified lines |
| 115 | 98 | |
| 116 | 99 | let start = Instant::now(); |
| 117 | 100 | let mut segments = Vec::new(); |
| 118 | | − let mut segment = Segment { |
| 101 | + let mut segment = history::Segment { |
| 119 | 102 | _head: history.head.to_owned(), |
| 120 | 103 | history: vec![], |
| 121 | 104 | }; |
| @@ -196,7 +179,7 @@ pub fn crate_references_descending<'h>( · 74 unmodified lines |
| 196 | 179 | }, |
| 197 | 180 | Some(next_ref) => segments.push(std::mem::replace( |
| 198 | 181 | &mut segment, |
| 199 | | − Segment { |
| 182 | + history::Segment { |
| 200 | 183 | _head: next_ref, |
| 201 | 184 | history: vec![item], |
| 202 | 185 | }, |