Skip to content

Commit

Permalink
Merge pull request #50 from mlange-42/bugfis/missing-tags
Browse files Browse the repository at this point in the history
Fix for missing tags due to tag id inconsistency, increment version to 0.4.3

Tag ids/hashes are inconsistent in git2-rs / libgit2. Sometimes, the tag's id are separate ids of tags (find_tag), sometimes thay are the ids of the target commit.

To fix the problem, first look for the id with find_tag, then with find_commit if not found with find_tags.
  • Loading branch information
mlange-42 authored Jan 21, 2021
2 parents d370e8f + 6c6339e commit df3574b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "git-graph"
version = "0.4.2"
version = "0.4.3"
authors = ["Martin Lange <[email protected]>"]
description = "Command line tool to show clear git graphs arranged for your branching model"
repository = "https://github.com/mlange-42/git-graph.git"
Expand Down
11 changes: 8 additions & 3 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,13 @@ fn extract_branches(
for (oid, name) in tags {
let name = std::str::from_utf8(&name[5..]).map_err(|err| err.to_string())?;

if let Ok(tag) = repository.find_tag(oid) {
if let Some(target_index) = indices.get(&tag.target_id()) {
let target = repository
.find_tag(oid)
.map(|tag| tag.target_id())
.or_else(|_| repository.find_commit(oid).map(|_| oid));

if let Ok(target_oid) = target {
if let Some(target_index) = indices.get(&target_oid) {
counter += 1;
let term_col = to_terminal_color(
&branch_color(
Expand All @@ -658,7 +663,7 @@ fn extract_branches(
counter,
);
let tag_info = BranchInfo::new(
tag.target_id(),
target_oid,
None,
name.to_string(),
settings.branches.persistence.len() as u8 + 1,
Expand Down

0 comments on commit df3574b

Please sign in to comment.