forge
Explore
Log in

Don't you dare go Hollow

Plain CI logs (run page log, plain log stream, previews) treat a carriage return like a terminal, showing only the last redraw instead of merging progress bars into one line

Browse files at this commit

7596a78527c434a4a31c5b0a292c8671fb9cafe9Ahmet Kaan GümüşParent: 7aca449
  • fix
    • plain CI logs (run page log, plain log stream, previews) treat a carriage return like a terminal, showing only the last redraw instead of merging progress bars into one line
Show full message
🐛 fix: plain CI logs (run page log, plain log stream, previews) treat a carriage return like a terminal, showing only the last redraw instead of merging progress bars into one line
crates/forge-ci/src/steps.rsmodified+1 -0
@@ -48,6 +48,7 @@ pub fn scan(bytes: &[u8], base_offset: u64, depth: &mut u32) -> Scan {
48 }48 }
49 49
50 pub fn strip_ansi(line: &str) -> String {50 pub fn strip_ansi(line: &str) -> String {
51+ let line = line.rsplit('\r').find(|part| !part.is_empty()).unwrap_or("");
51 let mut out = String::with_capacity(line.len());52 let mut out = String::with_capacity(line.len());
52 let mut chars = line.chars().peekable();53 let mut chars = line.chars().peekable();
53 while let Some(c) = chars.next() {54 while let Some(c) = chars.next() {
crates/forge-web-pages/src/pages/ci_runs.rsmodified+1 -0
@@ -3014,6 +3014,7 @@ mod tests {
3014 fn previews_skip_blank_lines_and_ansi_codes() {3014 fn previews_skip_blank_lines_and_ansi_codes() {
3015 assert_eq!(strip_ansi("\u{1b}[31mred\u{1b}[0m ok"), "red ok");3015 assert_eq!(strip_ansi("\u{1b}[31mred\u{1b}[0m ok"), "red ok");
3016 assert_eq!(strip_ansi("\u{1b}]0;title\u{7}x"), "x");3016 assert_eq!(strip_ansi("\u{1b}]0;title\u{7}x"), "x");
3017+ assert_eq!(strip_ansi("Building 1/2\r Compiling a\r"), " Compiling a");
3017 let tail = vec!["a".to_owned(), " b ".to_owned(), String::new()];3018 let tail = vec!["a".to_owned(), " b ".to_owned(), String::new()];
3018 assert_eq!(last_line(&tail), Some("b"));3019 assert_eq!(last_line(&tail), Some("b"));
3019 assert_eq!(last_line(&[]), None);3020 assert_eq!(last_line(&[]), None);