Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 734466201d1e
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d05d8030f0c4
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jan 25, 2019

  1. maintainer label: tag if submitter is a maintainer of each of their p…

    …ackages
    
    If the author of the PR is one of any number of maintainers, add the
    label. This is in contrast to the previous version, where the submitter
    of the PR had to be the ONLY maintainer on ANY package they touched.
    grahamc committed Jan 25, 2019
    Copy the full SHA
    d05d803 View commit details
Showing with 45 additions and 13 deletions.
  1. +23 −5 ofborg/src/maintainers.rs
  2. +20 −7 ofborg/src/tagger.rs
  3. +2 −1 ofborg/src/tasks/massrebuilder.rs
28 changes: 23 additions & 5 deletions ofborg/src/maintainers.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
use ofborg::nix::Nix;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::io::Write;
use std::path::Path;
use tempfile::NamedTempFile;

#[derive(Deserialize, Debug, Eq, PartialEq)]
pub struct ImpactedMaintainers(HashMap<Maintainer, Vec<Package>>);
#[derive(Deserialize, Debug, Eq, PartialEq, Hash)]
struct Maintainer(String);
pub struct MaintainersByPackage(pub HashMap<Package, HashSet<Maintainer>>);

#[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)]
pub struct Maintainer(String);
impl<'a> From<&'a str> for Maintainer {
fn from(name: &'a str) -> Maintainer {
Maintainer(name.to_owned())
}
}
#[derive(Deserialize, Debug, Eq, PartialEq, Hash)]
struct Package(String);
#[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)]
pub struct Package(String);
impl<'a> From<&'a str> for Package {
fn from(name: &'a str) -> Package {
Package(name.to_owned())
@@ -80,6 +82,22 @@ impl ImpactedMaintainers {
.map(|(maintainer, _)| maintainer.0.clone())
.collect()
}

pub fn maintainers_by_package(&self) -> MaintainersByPackage {
let mut bypkg = MaintainersByPackage(HashMap::new());

for (maintainer, packages) in self.0.iter() {
for package in packages.iter() {
bypkg
.0
.entry(package.clone())
.or_insert_with(HashSet::new)
.insert(maintainer.clone());
}
}

bypkg
}
}

impl std::fmt::Display for ImpactedMaintainers {
27 changes: 20 additions & 7 deletions ofborg/src/tagger.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::maintainers::{Maintainer, MaintainersByPackage};
use ofborg::outpathdiff::PackageArch;
use ofborg::tasks;
use std::collections::HashMap;
@@ -269,15 +270,27 @@ impl MaintainerPRTagger {
Default::default()
}

pub fn record_maintainer(&mut self, pr_submitter: &str, identified_maintainers: &[String]) {
let mut compare_to: Vec<String> = identified_maintainers.to_vec().clone();
compare_to.sort();
compare_to.dedup();
pub fn record_maintainer(
&mut self,
pr_submitter: &str,
identified_maintainers: &MaintainersByPackage,
) {
let submitter = Maintainer::from(pr_submitter);

if compare_to.len() == 1 && compare_to.contains(&pr_submitter.to_string()) {
self.selected
.push(String::from("11.by: package-maintainer"));
if identified_maintainers.0.is_empty() {
// No packages -> not from the maintainer
return;
}

for (_package, maintainers) in identified_maintainers.0.iter() {
if !maintainers.contains(&submitter) {
// One of the packages is not maintained by this submitter
return;
}
}

self.selected
.push(String::from("11.by: package-maintainer"));
}

pub fn tags_to_add(&self) -> Vec<String> {
3 changes: 2 additions & 1 deletion ofborg/src/tasks/massrebuilder.rs
Original file line number Diff line number Diff line change
@@ -572,7 +572,8 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for MassRebuildWorker<E
if let Ok(ref maint) = m {
request_reviews(&maint, &pull);
let mut maint_tagger = MaintainerPRTagger::new();
maint_tagger.record_maintainer(&issue.user.login, &maint.maintainers());
maint_tagger
.record_maintainer(&issue.user.login, &maint.maintainers_by_package());
update_labels(
&issue_ref,
&maint_tagger.tags_to_add(),