Compare commits

..
Author SHA1 Message Date
Patrick szymkowiak 8678bd8e32 fix: remove version check from validate-docs CI (#476)
Release-please bumps Cargo.toml but not docs, causing the version
grep to fail after every release. The check adds no value since docs
don't need to track the exact patch version.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-03-12 18:53:20 +01:00
3 changed files with 23 additions and 71 deletions

No files matched your search

+1 -1
View File
@@ -434,7 +434,7 @@ if command -v gt &>/dev/null; then
assert_help "rtk gt" rtk gt --help
assert_ok "rtk gt log short" rtk gt log short
else
skip_test "rtk gt" "gt not installed"
skip "gt not installed"
fi
# ── 30. Global flags ────────────────────────────────
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::tracking;
use crate::utils::{resolved_command, truncate};
use crate::utils::resolved_command;
use anyhow::{Context, Result};
use std::collections::HashMap;
use std::ffi::OsString;
+21 -69
View File
@@ -1,5 +1,5 @@
use crate::tracking;
use crate::utils::resolved_command;
use crate::utils::{resolved_command, truncate};
use anyhow::{Context, Result};
use std::ffi::OsString;
use std::process::Command;
@@ -361,10 +361,8 @@ fn run_log(
});
// Apply RTK defaults only if user didn't specify them
// Use %b (body) to preserve first line of commit body for agent context
// (BREAKING CHANGE, Closes #xxx, design notes)
if !has_format_flag {
cmd.args(["--pretty=format:%h %s (%ar) <%an>%n%b%n---END---"]);
cmd.args(["--pretty=format:%h %s (%ar) <%an>"]);
}
// Determine limit: respect user's explicit -N flag, use sensible defaults otherwise
@@ -470,39 +468,23 @@ fn parse_user_limit(args: &[String]) -> Option<usize> {
/// wider truncation threshold (120 chars) to preserve commit context that LLMs
/// need for rebase/squash operations.
fn filter_log_output(output: &str, limit: usize, user_set_limit: bool) -> String {
let lines: Vec<&str> = output.lines().collect();
let truncate_width = if user_set_limit { 120 } else { 80 };
// Split output into commit blocks separated by ---END---
let commits: Vec<&str> = output.split("---END---").collect();
let max_commits = if user_set_limit { commits.len() } else { limit };
let iter = lines.iter();
let capped: Vec<String> = if user_set_limit {
// User chose the limit → git already returned the right number of commits
iter.map(|line| truncate_line(line, truncate_width))
.collect()
} else {
// RTK default → cap output lines
iter.take(limit)
.map(|line| truncate_line(line, truncate_width))
.collect()
};
let mut result = Vec::new();
for block in commits.iter().take(max_commits) {
let block = block.trim();
if block.is_empty() {
continue;
}
let mut lines = block.lines();
// First line is the header: hash subject (date) <author>
let header = match lines.next() {
Some(h) => truncate_line(h.trim(), truncate_width),
None => continue,
};
// Remaining lines are the body — keep first non-empty line only
let body_line = lines.map(|l| l.trim()).find(|l| {
!l.is_empty() && !l.starts_with("Signed-off-by:") && !l.starts_with("Co-authored-by:")
});
match body_line {
Some(body) => {
let truncated_body = truncate_line(body, truncate_width);
result.push(format!("{}\n {}", header, truncated_body));
}
None => result.push(header),
}
}
result.join("\n").trim().to_string()
capped.join("\n").trim().to_string()
}
/// Truncate a single line to `width` characters, appending "..." if needed
@@ -1469,13 +1451,8 @@ mod tests {
#[test]
fn test_git_cmd_no_global_args() {
let cmd = git_cmd(&[]);
let program = cmd.get_program().to_string_lossy().to_string();
// resolved_command may return absolute path (e.g. /usr/bin/git)
assert!(
program == "git" || program.ends_with("/git"),
"Expected program to be 'git', got '{}'",
program
);
let program = cmd.get_program();
assert_eq!(program, "git");
let args: Vec<_> = cmd.get_args().collect();
assert!(args.is_empty());
}
@@ -1699,38 +1676,13 @@ M file7.rs
#[test]
fn test_filter_log_output() {
let output = "abc1234 This is a commit message (2 days ago) <author>\n\n---END---\ndef5678 Another commit (1 week ago) <other>\n\n---END---\n";
let output = "abc1234 This is a commit message (2 days ago) <author>\ndef5678 Another commit (1 week ago) <other>\n";
let result = filter_log_output(output, 10, false);
assert!(result.contains("abc1234"));
assert!(result.contains("def5678"));
assert_eq!(result.lines().count(), 2);
}
#[test]
fn test_filter_log_output_with_body() {
// Commit with body: first non-trailer body line should appear indented
let output = "abc1234 feat: add feature (2 days ago) <author>\nBREAKING CHANGE: removed old API\nSigned-off-by: Author <a@b.com>\n---END---\ndef5678 fix: typo (1 day ago) <other>\n\n---END---\n";
let result = filter_log_output(output, 10, false);
assert!(result.contains("abc1234"));
assert!(result.contains("BREAKING CHANGE: removed old API"));
assert!(!result.contains("Signed-off-by:"));
// def5678 has no body — just header
assert!(result.contains("def5678"));
// 3 lines: header1, body1 indented, header2
assert_eq!(result.lines().count(), 3);
}
#[test]
fn test_filter_log_output_skips_trailers() {
// Body with only trailers should not produce a body line
let output = "abc1234 chore: bump (1 day ago) <bot>\nSigned-off-by: Bot <bot@ci>\nCo-authored-by: Human <h@b>\n---END---\n";
let result = filter_log_output(output, 10, false);
assert!(result.contains("abc1234"));
assert!(!result.contains("Signed-off-by:"));
assert!(!result.contains("Co-authored-by:"));
assert_eq!(result.lines().count(), 1);
}
#[test]
fn test_filter_log_output_truncate_long() {
let long_line = "abc1234 ".to_string() + &"x".repeat(100) + " (2 days ago) <author>";
@@ -1743,7 +1695,7 @@ M file7.rs
#[test]
fn test_filter_log_output_cap_lines() {
let output = (0..20)
.map(|i| format!("hash{} message {} (1 day ago) <author>\n\n---END---", i, i))
.map(|i| format!("hash{} message {} (1 day ago) <author>", i, i))
.collect::<Vec<_>>()
.join("\n");
let result = filter_log_output(&output, 5, false);
@@ -1754,7 +1706,7 @@ M file7.rs
fn test_filter_log_output_user_limit_no_cap() {
// When user explicitly passes -N, all N lines should be returned (no re-truncation)
let output = (0..20)
.map(|i| format!("hash{} message {} (1 day ago) <author>\n\n---END---", i, i))
.map(|i| format!("hash{} message {} (1 day ago) <author>", i, i))
.collect::<Vec<_>>()
.join("\n");
let result = filter_log_output(&output, 20, true);