~/selfhut

6f4315909be571bde648228cb634fdb2f4f0694b — Arthur Melton b1605a54 2 years ago
cargo fix and some more
3 files changed, 5 insertions(+), 12 deletions(-)

M src/git/commits.rs
M src/git/tag.rs
M src/repository/refs.rs
M src/git/commits.rs => src/git/commits.rs +1 -1
@@ 25,7 25,7 @@ pub fn get_commits(

                    Err(_) => {
                        let mut tag = None;
                        let tag_name = id.as_bytes();
                        repo.tag_foreach(|x,y| {
                        let _ = repo.tag_foreach(|x,y| {
                            if &y[10..] == tag_name {
                                tag = Some(x);
                                return false;

M src/git/tag.rs => src/git/tag.rs +1 -1
@@ 9,7 9,7 @@ pub fn get_tag(repo_name: String, amount: usize, after: usize, name: Option<Stri

    let mut tags = Vec::new();
    let total = repo.tag_names(None).ok()?.len();
    let mut i = total-1;
    repo.tag_foreach(|x,y| {
    let _ = repo.tag_foreach(|x,y| {
        if (name.is_some() && name.as_ref().unwrap().as_bytes() == &y[10..]) || name.is_none() {
            if i >= after && (total < amount + after ||  i < amount - after) {
                match get_commits(repo_name.clone(), 1, Some(x.to_string()), None) {

M src/repository/refs.rs => src/repository/refs.rs +3 -10
@@ 1,24 1,17 @@

use crate::config::CONFIG;
use crate::git::branches::branches;

use crate::git::main_branch::main_branch;

use crate::git::tag::get_tag;
use crate::utils::repo_config::repo_config;
use rocket_dyn_templates::{context, Template};

#[get("/<repo>/refs?<page>", rank = 2)]
pub fn refs(repo: String, page: Option<usize>) -> Option<Template> {
    let mut tags = get_tag(repo.clone(), 11, (page.unwrap_or(1)-1)*10, None);
    let mut tags = get_tag(repo.clone(), 10, (page.unwrap_or(1)-1)*10, None);
    let mut pages = 1;
    let mut forward = false;
    match tags {
        Some(ref mut x) => {
                pages = x.1/10+1;
                if x.0.len() == 11 {
                    forward = true;
                    x.0.pop();
                }
            },
        Some(ref mut x) => pages = x.1/10+1,
        None => {}
    }
    Some(Template::render(