~/selfhut

77419c976038ae92fedb96e39ec1441f29019dab — Arthur Melton e4d868e2 2 years ago
dont minus one
2 files changed, 12 insertions(+), 5 deletions(-)

M src/git/tag.rs
M src/repository/commit.rs
M src/git/tag.rs => src/git/tag.rs +1 -1
@@ 13,7 13,7 @@ pub fn get_tag(

    let repo = git2::Repository::open(repo_path).ok()?;
    let mut tags = Vec::new();
    let total = repo.tag_names(None).ok()?.len();
    let mut i = total - 1;
    let mut i = total;
    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) {

M src/repository/commit.rs => src/repository/commit.rs +11 -4
@@ 120,14 120,21 @@ pub fn commit(repo: String, oid: String) -> Option<Template> {

}

#[get("/<repo>/patch/<oid>", rank = 2)]
pub fn patch(repo: String, oid: String) -> Option<Vec<u8>> {
pub fn patch(repo: String, oid: String) -> Option<String> {
    let mut repo_path = CONFIG.git_location.clone();
    repo_path.push(format!("{}.git", repo));
    let _repo_clone = repo.clone();
    let repo_clone = repo.clone();
    let repo = git2::Repository::open(repo_path).ok()?;
    let commit = repo.find_commit(git2::Oid::from_str(&oid).ok()?).ok()?;
    let _diff = diffs(commit, &repo)?;
    None
    let mut data = "".to_string();
    let diff = diffs(commit, &repo)?;
    let mut x = 0;
    for i in diff.deltas() {
        let mut patch = git2::Patch::from_diff(&diff, x).ok()??;
        data.push_str(patch.to_buf().ok()?.as_str()?);
        x+=1;
    }
    Some(data)
}

#[derive(Serialize, Clone)]