Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/prek-consts/src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl EnvVars {
pub const SSL_CERT_FILE: &'static str = "SSL_CERT_FILE";
pub const PREK_CONTAINER_RUNTIME: &'static str = "PREK_CONTAINER_RUNTIME";
pub const PREK_QUIET: &'static str = "PREK_QUIET";
pub const PREK_LOG_TRUNCATE_LIMIT: &'static str = "PREK_LOG_TRUNCATE_LIMIT";

// PREK internal environment variables
pub const PREK_INTERNAL__TEST_DIR: &'static str = "PREK_INTERNAL__TEST_DIR";
Expand Down
12 changes: 11 additions & 1 deletion crates/prek/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,23 @@ use std::fmt::Display;
use std::path::Path;
use std::process::Output;
use std::process::{CommandArgs, CommandEnvs, ExitStatus, Stdio};
use std::sync::LazyLock;

use owo_colors::OwoColorize;
use prek_consts::env_vars::EnvVars;
use thiserror::Error;
use tracing::trace;

use crate::git::GIT;

static LOG_TRUNCATE_LIMIT: LazyLock<usize> = LazyLock::new(|| {
EnvVars::var(EnvVars::PREK_LOG_TRUNCATE_LIMIT)
.ok()
.and_then(|limit| limit.parse::<usize>().ok())
.filter(|limit| *limit > 0)
.unwrap_or(120)
Comment thread
j178 marked this conversation as resolved.
Resolved
});
Comment thread
j178 marked this conversation as resolved.
Resolved

/// An error from executing a Command
#[derive(Debug, Error)]
pub enum Error {
Expand Down Expand Up @@ -495,7 +505,7 @@ impl Display for Cmd {
}
write!(f, " {}", arg.to_string_lossy())?;
len += arg.len() + 1;
if len > 120 {
if len > *LOG_TRUNCATE_LIMIT {
write!(f, " [...]",)?;
break;
}
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,8 @@ prek supports the following environment variables:
- `podman`
- `container` (Apple's Container runtime on macOS, see [container](https://github.com/apple/container))

- `PREK_LOG_TRUNCATE_LIMIT` — Control the truncation limit for command lines shown in trace logs (`Executing ...`). Defaults to `120` characters of arguments; set a larger value to reduce truncation.
Comment thread
j178 marked this conversation as resolved.
Resolved

Compatibility fallbacks:

- `PRE_COMMIT_ALLOW_NO_CONFIG` — Fallback for `PREK_ALLOW_NO_CONFIG`.
Expand Down
Loading