~/selfhut

75ab066976c1416150d80ae30545ab051b518617 — Arthur Melton 5ec2ce6e 2 years ago
format
1 files changed, 23 insertions(+), 22 deletions(-)

M src/git/commits.rs
M src/git/commits.rs => src/git/commits.rs +23 -22
@@ 32,36 32,37 @@ pub fn get_commits(

                if path.is_some() {
                    let path_value = path.as_ref().unwrap();
                    match repo_commit.tree() {
                        Ok(tree) => {
                                match repo_commit.parent(0) {
                                    Ok(parent) => {
                                        match parent.tree() {
                                            Ok(parent_tree) => {
                                                match repo.diff_tree_to_tree(Some(&tree), Some(&parent_tree), None) {
                                                    Ok(diff) => {
                                                        let files = diff.deltas()
                                                            .map(|i| i.new_file().path())
                                                            .filter(|i| i.is_some())
                                                            .map(|i| i.unwrap().to_string_lossy())
                                                            .filter(|i| i.starts_with(path_value))
                                                            .count();
                                                        allowed = files > 0;
                                                    },
                                                    Err(_) => {}
                                                }

                                            }
                                            Err(_) => {}
                        Ok(tree) => match repo_commit.parent(0) {
                            Ok(parent) => match parent.tree() {
                                Ok(parent_tree) => {
                                    match repo.diff_tree_to_tree(
                                        Some(&tree),
                                        Some(&parent_tree),
                                        None,
                                    ) {
                                        Ok(diff) => {
                                            let files = diff
                                                .deltas()
                                                .map(|i| i.new_file().path())
                                                .filter(|i| i.is_some())
                                                .map(|i| i.unwrap().to_string_lossy())
                                                .filter(|i| i.starts_with(path_value))
                                                .count();
                                            allowed = files > 0;
                                        }
                                        Err(_) => {}
                                    }
                                    Err(_) => {}
                                }
                                Err(_) => {}
                            },
                            Err(_) => {}
                        },
                        Err(_) => {}
                    }
                }
                if allowed {
                    let time = Duration::seconds(repo_commit.time().seconds() - Utc::now().timestamp());
                    let time =
                        Duration::seconds(repo_commit.time().seconds() - Utc::now().timestamp());
                    commits.push(Commits {
                        commit_hash: commit_rev.to_string(),
                        commit: repo_commit.message().unwrap_or("").to_string(),