diff --git a/src/git_entity/commit.rs b/src/git_entity/commit.rs index 823a6ad..647e23d 100644 --- a/src/git_entity/commit.rs +++ b/src/git_entity/commit.rs @@ -2,6 +2,8 @@ use crate::error::LumenError; use std::process::Command; use thiserror::Error; +use super::GIT_DIFF_EXCLUSIONS; + #[derive(Error, Debug, Clone)] pub enum CommitError { #[error("Commit '{0}' not found")] @@ -64,6 +66,7 @@ impl Commit { "--compact-summary", sha, ]) + .args(GIT_DIFF_EXCLUSIONS) .output()?; let diff = String::from_utf8(output.stdout)?; @@ -82,8 +85,8 @@ impl Commit { let mut message = String::from_utf8(output.stdout)?; message.pop(); // Remove trailing newline if message.ends_with('\n') { - message.pop(); // Remove the second trailing newline in commits where it exists (the ones not from github GUI) - } + message.pop(); // Remove the second trailing newline in commits where it exists (the ones not from github GUI) + } Ok(message) } diff --git a/src/git_entity/diff.rs b/src/git_entity/diff.rs index bff97aa..52b67cd 100644 --- a/src/git_entity/diff.rs +++ b/src/git_entity/diff.rs @@ -1,7 +1,7 @@ use crate::error::LumenError; use thiserror::Error; -use super::commit::Commit; +use super::{commit::Commit, GIT_DIFF_EXCLUSIONS}; #[derive(Error, Debug)] pub enum DiffError { @@ -30,7 +30,10 @@ impl Diff { vec!["diff"] }; - let output = std::process::Command::new("git").args(args).output()?; + let output = std::process::Command::new("git") + .args(args) + .args(GIT_DIFF_EXCLUSIONS) + .output()?; let diff = String::from_utf8(output.stdout)?; if diff.is_empty() { @@ -49,6 +52,7 @@ impl Diff { let output = std::process::Command::new("git") .args(["diff", &range]) + .args(GIT_DIFF_EXCLUSIONS) .output()?; let diff = String::from_utf8(output.stdout)?; diff --git a/src/git_entity/mod.rs b/src/git_entity/mod.rs index 158f783..137cfbc 100644 --- a/src/git_entity/mod.rs +++ b/src/git_entity/mod.rs @@ -13,6 +13,16 @@ pub enum GitEntity { Diff(Diff), } +pub const GIT_DIFF_EXCLUSIONS: [&str; 7] = [ + "--", // Separator for pathspecs + ".", // Include everything + ":(exclude)package-lock.json", + ":(exclude)yarn.lock", + ":(exclude)pnpm-lock.yaml", + ":(exclude)Cargo.lock", + ":(exclude)node_modules/**", +]; + impl GitEntity { pub fn format_static_details(&self, provider: &LumenProvider) -> String { match self {