huskies: merge 927
This commit is contained in:
@@ -86,6 +86,7 @@ pub(super) fn handle_cost(ctx: &CommandContext) -> Option<String> {
|
||||
///
|
||||
/// Agent names like "coder-1", "qa-2", "mergemaster" map to types "coder",
|
||||
/// "qa", "mergemaster". If the name ends with `-<digits>`, strip the suffix.
|
||||
#[allow(clippy::string_slice)] // pos comes from rfind('-'), so pos+1 is after an ASCII '-' → valid boundary
|
||||
pub(super) fn extract_agent_type(agent_name: &str) -> String {
|
||||
if let Some(pos) = agent_name.rfind('-') {
|
||||
let suffix = &agent_name[pos + 1..];
|
||||
|
||||
@@ -240,6 +240,7 @@ fn parse_coverage_output(output: &str, passed: bool) -> String {
|
||||
}
|
||||
|
||||
/// Extract a value from lines like `"Rust line coverage: 62.5%"`.
|
||||
#[allow(clippy::string_slice)] // starts_with(prefix) guarantees prefix.len() is a char boundary
|
||||
fn extract_line_value(output: &str, prefix: &str) -> Option<String> {
|
||||
output
|
||||
.lines()
|
||||
@@ -248,6 +249,7 @@ fn extract_line_value(output: &str, prefix: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
/// Extract a value from the summary block: `" Overall: 62.5%"`.
|
||||
#[allow(clippy::string_slice)] // starts_with(label) guarantees label.len() is a char boundary
|
||||
fn extract_summary_field(output: &str, label: &str) -> Option<String> {
|
||||
output
|
||||
.lines()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//! HEAD, formatted for readability in chat.
|
||||
|
||||
use super::CommandContext;
|
||||
use crate::chat::util::truncate_at_char_boundary;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -125,18 +126,6 @@ fn run_git(dir: &Path, args: &[&str]) -> String {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Truncate `s` to at most `max_bytes` bytes without splitting a UTF-8 character.
|
||||
fn truncate_at_char_boundary(s: &str, max_bytes: usize) -> &str {
|
||||
if s.len() <= max_bytes {
|
||||
return s;
|
||||
}
|
||||
let mut boundary = max_bytes;
|
||||
while !s.is_char_boundary(boundary) {
|
||||
boundary -= 1;
|
||||
}
|
||||
&s[..boundary]
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Tests
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use super::CommandContext;
|
||||
|
||||
/// Show compact git status: branch, uncommitted files, ahead/behind remote.
|
||||
#[allow(clippy::string_slice)] // line[..2] and line[3..]: git porcelain XY status codes are always ASCII
|
||||
pub(super) fn handle_git(ctx: &CommandContext) -> Option<String> {
|
||||
use std::process::Command;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use super::CommandContext;
|
||||
/// git diff --stat (files changed with line counts), and extracts key
|
||||
/// function/struct/type names added or modified in the implementation.
|
||||
/// Returns a friendly message when no merge commit is found.
|
||||
#[allow(clippy::string_slice)] // commit_hash is hex (ASCII), min(8) always within bounds
|
||||
pub(super) fn handle_overview(ctx: &CommandContext) -> Option<String> {
|
||||
let num_str = ctx.args.trim();
|
||||
if num_str.is_empty() {
|
||||
@@ -129,6 +130,7 @@ fn get_commit_stat(root: &std::path::Path, hash: &str) -> String {
|
||||
///
|
||||
/// Scans added lines (`+`) for Rust `fn`, `struct`, `enum`, `type`, `trait`,
|
||||
/// and `impl` declarations and returns them formatted as `` `Name` (kind) ``.
|
||||
#[allow(clippy::string_slice)] // line starts with '+' (ASCII), so &line[1..] is always a valid boundary
|
||||
fn extract_diff_symbols(root: &std::path::Path, hash: &str) -> Vec<String> {
|
||||
use std::process::Command;
|
||||
let output = Command::new("git")
|
||||
|
||||
@@ -123,6 +123,7 @@ fn parse_test_counts(output: &str) -> (u64, u64) {
|
||||
(total_passed, total_failed)
|
||||
}
|
||||
|
||||
#[allow(clippy::string_slice)] // pos from line.find(label) → always a char boundary
|
||||
fn extract_count(line: &str, label: &str) -> Option<u64> {
|
||||
let pos = line.find(label)?;
|
||||
let before = line[..pos].trim_end();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use super::CommandContext;
|
||||
|
||||
/// Strip YAML front matter and return a summary of useful fields + the remaining body.
|
||||
#[allow(clippy::string_slice)] // indices from find("\n---") on ASCII delimiter; "---" and "\n---" are ASCII-only
|
||||
fn strip_front_matter(text: &str) -> (String, String) {
|
||||
let trimmed = text.trim_start();
|
||||
if !trimmed.starts_with("---") {
|
||||
|
||||
@@ -462,7 +462,7 @@ fn status_shows_crdt_done_story_in_done_not_backlog() {
|
||||
);
|
||||
|
||||
// Verify it's not in Backlog section specifically.
|
||||
let backlog_section = &output[backlog_pos..done_pos];
|
||||
let backlog_section = output.get(backlog_pos..done_pos).unwrap_or("");
|
||||
assert!(
|
||||
!backlog_section.contains("503"),
|
||||
"503 must not appear in Backlog section: {backlog_section}"
|
||||
@@ -573,10 +573,16 @@ fn merge_item_failure_snippet_truncated_at_120_chars() {
|
||||
);
|
||||
// The snippet should not exceed 120 chars plus the ellipsis character.
|
||||
let snippet_start = output.find("\u{26D4}").expect("stop sign must be present");
|
||||
let line = output[snippet_start..].lines().next().unwrap_or("");
|
||||
let line = output
|
||||
.get(snippet_start..)
|
||||
.unwrap_or("")
|
||||
.lines()
|
||||
.next()
|
||||
.unwrap_or("");
|
||||
// Find the last " — " separator (before the snippet) and take what follows.
|
||||
if let Some(sep_pos) = line.rfind(" \u{2014} ") {
|
||||
let snippet = &line[sep_pos + 5..]; // " — " is 5 bytes (space + 3-byte em dash + space)
|
||||
// " — " is 5 bytes (space + 3-byte em dash + space)
|
||||
let snippet = line.get(sep_pos + 5..).unwrap_or("");
|
||||
assert!(
|
||||
snippet.chars().count() <= 122, // 120 chars + "…" (1 char) + possible trailing
|
||||
"snippet should be at most ~121 chars: {snippet}"
|
||||
|
||||
Reference in New Issue
Block a user