| @@ -8,27 +8,10 @@ use git_repository::{ · 7 unmodified lines |
| 8 | prelude::{CacheAccessExt, ObjectAccessExt, ReferenceAccessExt, ReferenceExt}, | 8 | prelude::{CacheAccessExt, ObjectAccessExt, ReferenceAccessExt, ReferenceExt}, |
| 9 | }; | 9 | }; |
| 10 | | 10 | |
| | 11 | use crate::command::changelog_impl::{history, History}; |
| 11 | use crate::utils::{component_to_bytes, is_tag_name, is_tag_version, package_by_name, tag_prefix}; | 12 | use crate::utils::{component_to_bytes, is_tag_name, is_tag_version, package_by_name, tag_prefix}; |
| 12 | use std::cell::RefCell; | 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 | pub fn commit_history(repo: &git::Easy) -> anyhow::Result<Option<History>> { | 15 | pub fn commit_history(repo: &git::Easy) -> anyhow::Result<Option<History>> { |
| 33 | let start = Instant::now(); | 16 | let start = Instant::now(); |
| 34 | let prev = repo.object_cache_size(64 * 1024)?; | 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 | (commit.message.to_owned(), commit.tree()) | 30 | (commit.message.to_owned(), commit.tree()) |
| 48 | }; | 31 | }; |
| 49 | | 32 | |
| 50 | items.push(HistoryItem { | 33 | items.push(history::Item { |
| 51 | id: commit_id.detach(), | 34 | id: commit_id.detach(), |
| 52 | _message: message, | 35 | _message: message, |
| 53 | tree_data: repo.find_object(tree_id)?.data.to_owned(), | 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 | /// Return the head reference followed by all tags affecting `crate_name` as per our tag name rules, ordered by ancestry. | 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 | crate_name: &str, | 56 | crate_name: &str, |
| 74 | ctx: &crate::Context, | 57 | ctx: &crate::Context, |
| 75 | history: &'h History, | 58 | history: &'h History, |
| 76 | ) -> anyhow::Result<Vec<Segment<'h>>> { | 59 | ) -> anyhow::Result<Vec<history::Segment<'h>>> { |
| 77 | let meta = &ctx.meta; | 60 | let meta = &ctx.meta; |
| 78 | let package = package_by_name(meta, crate_name)?; | 61 | let package = package_by_name(meta, crate_name)?; |
| 79 | let tag_prefix = tag_prefix(package, &ctx.repo); | 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 | let start = Instant::now(); | 99 | let start = Instant::now(); |
| 117 | let mut segments = Vec::new(); | 100 | let mut segments = Vec::new(); |
| 118 | let mut segment = Segment { | 101 | let mut segment = history::Segment { |
| 119 | _head: history.head.to_owned(), | 102 | _head: history.head.to_owned(), |
| 120 | history: vec![], | 103 | history: vec![], |
| 121 | }; | 104 | }; |
| @@ -196,7 +179,7 @@ pub fn crate_references_descending<'h>( · 74 unmodified lines |
| 196 | }, | 179 | }, |
| 197 | Some(next_ref) => segments.push(std::mem::replace( | 180 | Some(next_ref) => segments.push(std::mem::replace( |
| 198 | &mut segment, | 181 | &mut segment, |
| 199 | Segment { | 182 | history::Segment { |
| 200 | _head: next_ref, | 183 | _head: next_ref, |
| 201 | history: vec![item], | 184 | history: vec![item], |
| 202 | }, | 185 | }, |