mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
use new tag_foreach api
This commit is contained in:
parent
0c53fed624
commit
f83228548b
3 changed files with 20 additions and 24 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -389,9 +389,9 @@ checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
|
|||
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.13.6"
|
||||
version = "0.13.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11e4b2082980e751c4bf4273e9cbb4a02c655729c8ee8a79f66cad03c8f4d31e"
|
||||
checksum = "e6ac22e49b7d886b6802c66662b12609452248b1bc9e87d6d83ecea3db96f557"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
|
|
@ -527,9 +527,9 @@ checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
|
|||
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.12.7+1.0.0"
|
||||
version = "0.12.9+1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcd07968649bcb7b9351ecfde53ca4d27673cccfdf57c84255ec18710f3153e0"
|
||||
checksum = "9b33bf3d9d4c45b48ae1ea7c334be69994624dc0a69f833d5d9f7605f24b552b"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ keywords = ["git"]
|
|||
|
||||
[dependencies]
|
||||
scopetime = { path = "../scopetime", version = "0.1" }
|
||||
git2 = { version = "0.13.6", default-features = false }
|
||||
git2 = { version = "0.13.8", default-features = false }
|
||||
rayon-core = "1.7"
|
||||
crossbeam-channel = "0.4"
|
||||
log = "0.4"
|
||||
|
|
|
|||
|
|
@ -23,27 +23,23 @@ pub fn get_tags(repo_path: &str) -> Result<Tags> {
|
|||
|
||||
let repo = repo(repo_path)?;
|
||||
|
||||
//TODO: use tag_foreach once its released
|
||||
// see https://github.com/rust-lang/git2-rs/pull/595
|
||||
for name in repo.tag_names(None)?.iter() {
|
||||
if let Some(name) = name {
|
||||
let reference = repo.find_reference(
|
||||
format!("refs/tags/{}", name).as_str(),
|
||||
)?;
|
||||
let reference = reference.resolve()?;
|
||||
|
||||
let commit_id = if let Ok(tag) = reference.peel_to_tag() {
|
||||
Some(tag.target_id())
|
||||
} else {
|
||||
reference.target()
|
||||
};
|
||||
|
||||
if let Some(commit_id) = commit_id {
|
||||
let tag_name = String::from(name);
|
||||
adder(CommitId::new(commit_id), tag_name);
|
||||
repo.tag_foreach(|id, name| {
|
||||
if let Ok(name) =
|
||||
String::from_utf8(name[10..name.len()].into())
|
||||
{
|
||||
//NOTE: find_tag (git_tag_lookup) only works on annotated tags
|
||||
// lightweight tags `id` already points to the target commit
|
||||
// see https://github.com/libgit2/libgit2/issues/5586
|
||||
if let Ok(tag) = repo.find_tag(id) {
|
||||
adder(CommitId::new(tag.target_id()), name);
|
||||
} else if repo.find_commit(id).is_ok() {
|
||||
adder(CommitId::new(id), name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
})?;
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue