~/selfhut

selfhut/src/git/tag.rs -rw-r--r-- 655 B
00c0a257 — Arthur Melton format code 2 years ago

            
ef55c0da arthurmelton
b1605a54 Arthur Melton
ef55c0da arthurmelton
e4d868e2 Arthur Melton
ef55c0da arthurmelton
b1605a54 Arthur Melton
77419c97 Arthur Melton
e4d868e2 Arthur Melton
b1605a54 Arthur Melton
e4d868e2 Arthur Melton
0016c2cc arthurmelton
b1605a54 Arthur Melton
e4d868e2 Arthur Melton
b1605a54 Arthur Melton
e4d868e2 Arthur Melton
0016c2cc arthurmelton
b1605a54 Arthur Melton
e4d868e2 Arthur Melton
b1605a54 Arthur Melton
e4d868e2 Arthur Melton
b1605a54 Arthur Melton
ef55c0da arthurmelton



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::config::CONFIG;

pub fn get_tag(repo_name: String, amount: usize) -> Option<Vec<String>> {
    let mut repo_path = CONFIG.git_location.clone();
    repo_path.push(format!("{}.git", repo_name));
    let repo = git2::Repository::open(repo_path).ok()?;
    let mut tags = Vec::new();
    let mut i = 0;
    let repo_tags = repo.tag_names(None).ok()?;
    let mut tags_stringarray = repo_tags.iter().rev();
    let mut tag = tags_stringarray.next();
    while i < amount && tag.is_some() && tag.unwrap().is_some() {
        tags.push(tag.unwrap().unwrap().to_string());
        tag = tags_stringarray.next();
        i += 1;
    }
    Some(tags)
}