-
-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support showing tags in log, speed up log by cloning less (#47)
- Loading branch information
Stephan Dilly
committed
May 10, 2020
1 parent
ec6180a
commit 16aa6f7
Showing
3 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::utils::repo; | ||
use git2::Error; | ||
use scopetime::scope_time; | ||
use std::collections::HashMap; | ||
|
||
/// hashmap of tag target commit hash to tag name | ||
pub type Tags = HashMap<String, String>; | ||
|
||
/// returns `Tags` type filled with all tags found in repo | ||
pub fn get_tags(repo_path: &str) -> Result<Tags, Error> { | ||
scope_time!("get_tags"); | ||
|
||
let mut res = Tags::new(); | ||
|
||
let repo = repo(repo_path); | ||
|
||
for name in repo.tag_names(None)?.iter() { | ||
if let Some(name) = name { | ||
let obj = repo.revparse_single(name)?; | ||
|
||
if let Some(tag) = obj.as_tag() { | ||
let target_hash = tag.target_id().to_string(); | ||
let tag_name = String::from(name); | ||
res.insert(target_hash, tag_name); | ||
} | ||
} | ||
} | ||
|
||
Ok(res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters