Skip to content

Commit

Permalink
eval/nixpkgs: parse more commit messages
Browse files Browse the repository at this point in the history
Add support for expanding the Bash-like brace syntax and for removing
bracketed prefixes like [Backport ...].
  • Loading branch information
rhendric committed Jun 7, 2023
1 parent 0f34038 commit c3b9f3a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Example commit titles and the builds they will start:
| `vim: 1.0.0 -> 2.0.0` | `vim` |
| `vagrant: Fix dependencies for version 2.0.2 ` | `vagrant` |
| `python36Packages.requests,python27Packages.requests: 1.0.0 -> 2.0.0` | `python36Packages.requests`, `python27Packages.requests` |
| `python{2,3}Packages.requests: 1.0.0 -> 2.0.0` | _nothing_ |
| `python{2,3}Packages.requests: 1.0.0 -> 2.0.0` | `python2Packages.requests`, `python3Packages.requests` |

When opening a PR with multiple commits, ofborg creates a single build job for
all detected packages. If multiple commits get pushed to a PR one-by-one, each
Expand Down
1 change: 1 addition & 0 deletions ofborg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"

[dependencies]
async-std = { version = "=1.12.0", features = ["unstable", "tokio1"] }
brace-expand = "0.1.0"
chrono = "0.4.22"
either = "1.8.0"
fs2 = "0.4.3"
Expand Down
33 changes: 22 additions & 11 deletions ofborg/src/tasks/eval/nixpkgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::tasks::evaluate::{get_prefix, make_gist, update_labels};

use std::path::Path;

use brace_expand::brace_expand;
use chrono::Utc;
use hubcaps::checks::{CheckRunOptions, CheckRunState, Conclusion, Output};
use hubcaps::gists::Gists;
Expand Down Expand Up @@ -623,17 +624,18 @@ fn parse_commit_messages(messages: &[String]) -> Vec<String> {
.iter()
.filter_map(|line| {
// Convert "foo: some notes" in to "foo"
let parts: Vec<&str> = line.splitn(2, ':').collect();
if parts.len() == 2 {
Some(parts[0])
} else {
None
}
line.split_once(':').map(|(pre, _)| pre.trim())
})
.flat_map(|line| {
let pkgs: Vec<&str> = line.split(',').collect();
pkgs
.map(|line| {
// Remove such things as [Backport release-xx.xx]
if line.starts_with('[') {
if let Some((_, rest)) = line.split_once(']') {
return rest.trim_start();
}
}
line
})
.flat_map(|line| brace_expand(&format!("{{{}}}", line)))
.map(|line| line.trim().to_owned())
.collect()
}
Expand All @@ -646,15 +648,22 @@ mod tests {
#[test]
fn test_parse_commit_messages() {
let expect: Vec<&str> = vec![
"firefox{-esr", // don't support such fancy syntax
"}", // Don't support such fancy syntax
"firefox-esr",
"firefox",
"firefox",
"buildkite-agent",
"python.pkgs.ptyprocess",
"python.pkgs.ptyprocess",
"android-studio-preview",
"foo",
"bar",
"element-web",
"element-desktop",
"firefox",
"firefox-bin",
"firefox-beta",
"firefox-beta-bin",
"librewolf",
];
assert_eq!(
parse_commit_messages(
Expand All @@ -671,6 +680,8 @@ mod tests {
Merge pull request #34188 from dotlambda/home-assistant
Merge pull request #34414 from dotlambda/postfix
foo,bar: something here: yeah
[Backport release-23.05] element-{web,desktop}: 1.11.31 -> 1.11.32
firefox{,-beta}{,-bin}, librewolf: blah blah blah
"
.lines()
.map(|l| l.to_owned())
Expand Down

0 comments on commit c3b9f3a

Please sign in to comment.