History

minor refactor

Sebastian Thiel committed 4 years ago

Commit dae710f1 parent 0fb4c911 file · +7 −7Browse files

Unified · Split

cargo-smart-release/src/git/history.rs+7−7
@@ -29,12 +29,12 @@ pub enum SegmentScope { · 28 unmodified lines
29}29}
30 30
31pub fn collect(handle: &git::easy::Handle) -> anyhow::Result<Option<commit::History>> {31pub fn collect(handle: &git::easy::Handle) -> anyhow::Result<Option<commit::History>> {
32 let mut repo = handle.clone();32 let mut handle = handle.clone();
33 repo.object_cache_size(64 * 1024);33 handle.object_cache_size(64 * 1024);
34 let reference = match repo.head()?.peeled()?.kind {34 let reference = match handle.head()?.peeled()?.kind {
35 head::Kind::Detached { .. } => bail!("Refusing to operate on a detached head."),35 head::Kind::Detached { .. } => bail!("Refusing to operate on a detached head."),
36 head::Kind::Unborn { .. } => return Ok(None),36 head::Kind::Unborn { .. } => return Ok(None),
37 head::Kind::Symbolic(r) => r.attach(&repo),37 head::Kind::Symbolic(r) => r.attach(&handle),
38 };38 };
39 39
40 let mut items = Vec::new();40 let mut items = Vec::new();
@@ -60,7 +60,7 @@ pub fn collect(handle: &git::easy::Handle) -> anyhow::Result<Option<commit::Hist · 19 unmodified lines
60 (60 (
61 message,61 message,
62 tree_id,62 tree_id,
63 parent_commit_id.map(|id| id.attach(&repo).object().expect("present").to_commit_ref().tree()),63 parent_commit_id.map(|id| id.attach(&handle).object().expect("present").to_commit_ref().tree()),
64 commit_time,64 commit_time,
65 )65 )
66 };66 };
@@ -75,9 +75,9 @@ pub fn collect(handle: &git::easy::Handle) -> anyhow::Result<Option<commit::Hist · 8 unmodified lines
75 }75 }
76 Ok(m) => m,76 Ok(m) => m,
77 };77 };
78 data_by_tree_id.insert(tree_id, repo.find_object(tree_id)?.data.to_owned());78 data_by_tree_id.insert(tree_id, handle.find_object(tree_id)?.data.to_owned());
79 if let Some(tree_id) = parent_tree_id {79 if let Some(tree_id) = parent_tree_id {
80 data_by_tree_id.insert(tree_id, repo.find_object(tree_id)?.data.to_owned());80 data_by_tree_id.insert(tree_id, handle.find_object(tree_id)?.data.to_owned());
81 }81 }
82 items.push(commit::history::Item {82 items.push(commit::history::Item {
83 id: commit_id.detach(),83 id: commit_id.detach(),