mirror of
https://github.com/jnsahaj/lumen.git
synced 2025-07-07 21:35:10 +00:00
feat(git_entity): add GIT_DIFF_EXCLUSIONS for command-line git calls
This commit is contained in:
parent
17281c7f20
commit
c60b202b05
3 changed files with 21 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue