Skip to main content

pipedash_plugin_azure_devops/
log_dialect.rs

1use pipedash_plugin_actions::ActionsLogDialect;
2use pipedash_plugin_api::{
3    LineMarker,
4    LogDialect,
5    ParsedLine,
6};
7
8const SECTION: &[u8] = b"##[section]";
9const TASK_START: &[u8] = b"Starting: ";
10const TASK_END: &[u8] = b"Finishing: ";
11
12pub struct AzureDevOpsLogDialect;
13
14impl LogDialect for AzureDevOpsLogDialect {
15    fn parse<'a>(&self, line: &'a [u8]) -> ParsedLine<'a> {
16        let parsed = ActionsLogDialect.parse(line);
17        match (parsed.marker, parsed.body.strip_prefix(SECTION)) {
18            (LineMarker::Plain, Some(title)) => ParsedLine {
19                marker: if title.starts_with(TASK_END) {
20                    LineMarker::Plain
21                } else {
22                    LineMarker::SectionStart { open: false }
23                },
24                body: title,
25                ..parsed
26            },
27            _ => parsed,
28        }
29    }
30
31    fn is_step_start(&self, line: &ParsedLine<'_>) -> bool {
32        line.marker == (LineMarker::SectionStart { open: false })
33            && line.body.starts_with(TASK_START)
34    }
35
36    fn infers_errors(&self) -> bool {
37        false
38    }
39}
40
41#[cfg(test)]
42mod tests;