Skip to content

Commit

Permalink
Merge pull request #1998 from Kobzol/cmd-refactor
Browse files Browse the repository at this point in the history
Apply forgotten review changes to command parsing
  • Loading branch information
Kobzol authored Oct 14, 2024
2 parents e19c968 + 7c5fe16 commit 67739c3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions site/src/request_handlers/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ async fn handle_rust_timer(
return Ok(github::Response);
}

let build_cmds: Vec<_> = parse_build_commands(&comment.body).collect();
let mut valid_build_cmds = vec![];
let mut errors = String::new();
for cmd in build_cmds {
for cmd in parse_build_commands(&comment.body) {
match cmd {
Ok(cmd) => valid_build_cmds.push(cmd),
Err(error) => errors.push_str(&format!("Cannot parse build command: {error}\n")),
Expand Down Expand Up @@ -208,18 +207,15 @@ fn parse_build_commands(body: &str) -> impl Iterator<Item = Result<BuildCommand,
})
}

fn get_command_lines<'a: 'b, 'b>(
body: &'a str,
command: &'b str,
) -> impl Iterator<Item = &'a str> + 'b {
fn get_command_lines<'a>(body: &'a str, command: &'a str) -> impl Iterator<Item = &'a str> {
let prefix = "@rust-timer";
body.lines()
.filter_map(move |line| {
line.find(prefix)
.map(|index| line[index + prefix.len()..].trim())
})
.filter_map(move |line| line.strip_prefix(command))
.map(move |l| l.trim_start())
.map(|l| l.trim_start())
}

fn parse_benchmark_parameters<'a>(
Expand Down

0 comments on commit 67739c3

Please sign in to comment.