forked from the-distro/ofborg
eval/nixpkgs: parse Bash-braces in commits
Add support for expanding the Bash-like brace syntax.
This commit is contained in:
parent
653829c95e
commit
7101ab45ba
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -302,6 +302,12 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "brace-expand"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3adb80ee272c844254166ea32c8ae11c211b3639a293fdde41b1645b6be2c62"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.11.1"
|
version = "3.11.1"
|
||||||
|
@ -1291,6 +1297,7 @@ name = "ofborg"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
|
"brace-expand",
|
||||||
"chrono",
|
"chrono",
|
||||||
"either",
|
"either",
|
||||||
"fs2",
|
"fs2",
|
||||||
|
|
|
@ -20,7 +20,7 @@ Example commit titles and the builds they will start:
|
||||||
| `vim: 1.0.0 -> 2.0.0` | `vim` |
|
| `vim: 1.0.0 -> 2.0.0` | `vim` |
|
||||||
| `vagrant: Fix dependencies for version 2.0.2 ` | `vagrant` |
|
| `vagrant: Fix dependencies for version 2.0.2 ` | `vagrant` |
|
||||||
| `python36Packages.requests,python27Packages.requests: 1.0.0 -> 2.0.0` | `python36Packages.requests`, `python27Packages.requests` |
|
| `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
|
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
|
all detected packages. If multiple commits get pushed to a PR one-by-one, each
|
||||||
|
|
|
@ -7,6 +7,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-std = { version = "=1.12.0", features = ["unstable", "tokio1"] }
|
async-std = { version = "=1.12.0", features = ["unstable", "tokio1"] }
|
||||||
|
brace-expand = "0.1.0"
|
||||||
chrono = "0.4.22"
|
chrono = "0.4.22"
|
||||||
either = "1.8.0"
|
either = "1.8.0"
|
||||||
fs2 = "0.4.3"
|
fs2 = "0.4.3"
|
||||||
|
|
|
@ -16,6 +16,7 @@ use crate::tasks::evaluate::{get_prefix, make_gist, update_labels};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use brace_expand::brace_expand;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use hubcaps::checks::{CheckRunOptions, CheckRunState, Conclusion, Output};
|
use hubcaps::checks::{CheckRunOptions, CheckRunState, Conclusion, Output};
|
||||||
use hubcaps::gists::Gists;
|
use hubcaps::gists::Gists;
|
||||||
|
@ -623,17 +624,9 @@ fn parse_commit_messages(messages: &[String]) -> Vec<String> {
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|line| {
|
.filter_map(|line| {
|
||||||
// Convert "foo: some notes" in to "foo"
|
// Convert "foo: some notes" in to "foo"
|
||||||
let parts: Vec<&str> = line.splitn(2, ':').collect();
|
line.split_once(':').map(|(pre, _)| pre.trim())
|
||||||
if parts.len() == 2 {
|
|
||||||
Some(parts[0])
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.flat_map(|line| {
|
|
||||||
let pkgs: Vec<&str> = line.split(',').collect();
|
|
||||||
pkgs
|
|
||||||
})
|
})
|
||||||
|
.flat_map(|line| brace_expand(&format!("{{{}}}", line)))
|
||||||
.map(|line| line.trim().to_owned())
|
.map(|line| line.trim().to_owned())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -646,8 +639,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_commit_messages() {
|
fn test_parse_commit_messages() {
|
||||||
let expect: Vec<&str> = vec![
|
let expect: Vec<&str> = vec![
|
||||||
"firefox{-esr", // don't support such fancy syntax
|
"firefox-esr",
|
||||||
"}", // Don't support such fancy syntax
|
"firefox",
|
||||||
"firefox",
|
"firefox",
|
||||||
"buildkite-agent",
|
"buildkite-agent",
|
||||||
"python.pkgs.ptyprocess",
|
"python.pkgs.ptyprocess",
|
||||||
|
@ -655,6 +648,11 @@ mod tests {
|
||||||
"android-studio-preview",
|
"android-studio-preview",
|
||||||
"foo",
|
"foo",
|
||||||
"bar",
|
"bar",
|
||||||
|
"firefox",
|
||||||
|
"firefox-bin",
|
||||||
|
"firefox-beta",
|
||||||
|
"firefox-beta-bin",
|
||||||
|
"librewolf",
|
||||||
];
|
];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_commit_messages(
|
parse_commit_messages(
|
||||||
|
@ -671,6 +669,7 @@ mod tests {
|
||||||
Merge pull request #34188 from dotlambda/home-assistant
|
Merge pull request #34188 from dotlambda/home-assistant
|
||||||
Merge pull request #34414 from dotlambda/postfix
|
Merge pull request #34414 from dotlambda/postfix
|
||||||
foo,bar: something here: yeah
|
foo,bar: something here: yeah
|
||||||
|
firefox{,-beta}{,-bin}, librewolf: blah blah blah
|
||||||
"
|
"
|
||||||
.lines()
|
.lines()
|
||||||
.map(|l| l.to_owned())
|
.map(|l| l.to_owned())
|
||||||
|
|
Loading…
Reference in a new issue