Compare commits

...

4 Commits

Author SHA1 Message Date
hubert 5f6f7b7efe get_tags_nbr 2021-07-23 13:47:41 +02:00
hubert 1f4d08aff1 get_branches_nbr 2021-07-23 13:43:04 +02:00
hubert f71e8ff1b3 revisions_nbr 2021-07-23 13:35:14 +02:00
hubert 4134982739 login button works 2021-07-23 12:54:42 +02:00
4 changed files with 45 additions and 6 deletions

View File

@ -78,4 +78,28 @@ impl GitRepo {
return Ok(res);
}
pub fn get_revisions_nbr(&self) -> u32 {
let mut res = 0;
let mut revwalk = self.git2.revwalk().expect("revisions walk is not defined");
revwalk.push_head(); // todo : voir ce qu'il faut réellement pousser si on veux avoir TOUS les commits (genre par exemple si le HEAD n'est pas fils de tous les commits)
for _ in revwalk{
res = res + 1;
}
res
}
pub fn get_branches_nbr(&self) -> u32 {
let mut res = 0;
for _ in self.git2.branches(Some(BranchType::Local)){
res = res + 1;
}
res
}
pub fn get_tags_nbr(&self) -> u32 {
let mut res = 0;
self.git2.tag_foreach(|_,_| {res = res + 1;true});
res
}
}

View File

@ -46,6 +46,10 @@ where for <'a> &'a TS : IntoIterator<Item = &'a Entry>,
browse : TS,
root : ROOT,
user_opt : Option<User>,
revisions_nbr : u32,
branches_nbr : u32,
tags_nbr : u32,
size : String,
}
@ -109,5 +113,16 @@ pub async fn git_main<T : AuthValidator>(
}
}
}
Ok(GitMainTemplate { repo, browse : entries, root : path, user_opt : user})
Ok(GitMainTemplate {
repo,
browse : entries,
root : path,
user_opt : user,
revisions_nbr : gitrepo.get_revisions_nbr(),
branches_nbr : gitrepo.get_branches_nbr(),
tags_nbr : gitrepo.get_tags_nbr(),
size : "16 KiB".to_string(),
})
}

View File

@ -26,7 +26,7 @@
</div>
</div>
{% when None %}
<a href="#" class="w3-bar-item w3-button w3-right"><i class="fa fa-sign-in"></i> Log in</a>
<a href="?login=true" class="w3-bar-item w3-button w3-right"><i class="fa fa-sign-in"></i> Log in</a>
{% endmatch %}
</div>
{% block content %}{% endblock %}

View File

@ -26,16 +26,16 @@
<div class="w3-panel w3-border w3-cell-row">
<div class="w3-center w3-cell">
<i class="fa fa-history"></i> 112 revisions
<i class="fa fa-history"></i> {{ revisions_nbr }} revisions
</div>
<div class="w3-center w3-cell">
<i class="fa fa-code-branch"></i> 10 branches
<i class="fa fa-code-branch"></i> {{ branches_nbr }} branches
</div>
<div class="w3-center w3-cell">
<i class="fa fa-tag"></i> 5 tags
<i class="fa fa-tag"></i> {{ tags_nbr }} tags
</div>
<div class="w3-center w3-cell">
<i class="fa fa-database"></i> 10 KiB
<i class="fa fa-database"></i> {{ size }}
</div>
</div>