Skip to content

Commit c14e2d2

Browse files
committed
Handle temporary new bors e-mail
1 parent df8230b commit c14e2d2

File tree

3 files changed

+47
-39
lines changed

3 files changed

+47
-39
lines changed

src/git.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use git2::build::RepoBuilder;
1313
use git2::{Commit as Git2Commit, Repository};
1414
use log::debug;
1515

16-
use crate::{Author, Commit, GitDate, BORS_AUTHOR};
16+
use crate::{Author, Commit, GitDate, BORS_AUTHORS};
1717

1818
impl Commit {
1919
// Takes &mut because libgit2 internally caches summaries
@@ -153,9 +153,9 @@ pub fn get_commits_between(first_commit: &str, last_commit: &str) -> anyhow::Res
153153
// two commits are merge commits made by bors
154154
let assert_by_bors = |c: &Git2Commit<'_>| -> anyhow::Result<()> {
155155
match c.author().name() {
156-
Some(author) if author == BORS_AUTHOR => Ok(()),
156+
Some(author) if BORS_AUTHORS.contains(&author) => Ok(()),
157157
Some(author) => bail!(
158-
"Expected author {author} to be {BORS_AUTHOR} for {}.\n \
158+
"Expected author {author} to be one of {BORS_AUTHORS:?} for {}.\n \
159159
Make sure specified commits are on the default branch!",
160160
c.id()
161161
),
@@ -179,7 +179,12 @@ pub fn get_commits_between(first_commit: &str, last_commit: &str) -> anyhow::Res
179179
res.push(Commit::from_git2_commit(&mut current));
180180
match current.parents().next() {
181181
Some(c) => {
182-
if c.author().name() != Some(BORS_AUTHOR) {
182+
if !c
183+
.author()
184+
.name()
185+
.map(|name| BORS_AUTHORS.contains(&name))
186+
.unwrap_or(false)
187+
{
183188
debug!(
184189
"{:?} has non-bors author: {:?}, skipping",
185190
c.id(),

src/github.rs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use reqwest::header::{HeaderMap, HeaderValue, InvalidHeaderValue, AUTHORIZATION,
33
use reqwest::{blocking::Client, blocking::Response};
44
use serde::{Deserialize, Serialize};
55

6-
use crate::{parse_to_naive_date, Author, Commit, GitDate, BORS_AUTHOR};
6+
use crate::{parse_to_naive_date, Author, Commit, GitDate, BORS_AUTHORS};
77

88
#[derive(Serialize, Deserialize, Debug)]
99
struct GithubCommitComparison {
@@ -141,42 +141,44 @@ impl CommitsQuery<'_> {
141141

142142
// focus on Pull Request merges, all authored and committed by bors.
143143
let client = Client::builder().default_headers(headers()?).build()?;
144-
for page in 1.. {
145-
let url = CommitsUrl {
146-
page,
147-
author: BORS_AUTHOR,
148-
since: self.since_date,
149-
sha: self.most_recent_sha,
150-
}
151-
.url();
152-
153-
let response: Response = client.get(&url).send()?;
154-
let status = response.status();
155-
if !status.is_success() {
156-
bail!(
157-
"error: url <{}> response {}: {}",
158-
url,
159-
status,
160-
response.text().unwrap_or_else(|_| format!("<empty>"))
161-
);
162-
}
144+
for bors_author in BORS_AUTHORS {
145+
for page in 1.. {
146+
let url = CommitsUrl {
147+
page,
148+
author: bors_author,
149+
since: self.since_date,
150+
sha: self.most_recent_sha,
151+
}
152+
.url();
163153

164-
let action = parse_paged_elems(response, |elem: GithubCommitElem| {
165-
let found_last = elem.sha == self.earliest_sha;
166-
if found_last {
167-
eprintln!(
168-
"ending github query because we found starting sha: {}",
169-
elem.sha
154+
let response: Response = client.get(&url).send()?;
155+
let status = response.status();
156+
if !status.is_success() {
157+
bail!(
158+
"error: url <{}> response {}: {}",
159+
url,
160+
status,
161+
response.text().unwrap_or_else(|_| format!("<empty>"))
170162
);
171163
}
172-
let commit = elem.git_commit()?;
173-
commits.push(commit);
174164

175-
Ok(if found_last { Loop::Break } else { Loop::Next })
176-
})?;
165+
let action = parse_paged_elems(response, |elem: GithubCommitElem| {
166+
let found_last = elem.sha == self.earliest_sha;
167+
if found_last {
168+
eprintln!(
169+
"ending github query because we found starting sha: {}",
170+
elem.sha
171+
);
172+
}
173+
let commit = elem.git_commit()?;
174+
commits.push(commit);
175+
176+
Ok(if found_last { Loop::Break } else { Loop::Next })
177+
})?;
177178

178-
if let Loop::Break = action {
179-
break;
179+
if let Loop::Break = action {
180+
break;
181+
}
180182
}
181183
}
182184

src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ use crate::toolchains::{
3636
ToolchainSpec, YYYY_MM_DD,
3737
};
3838

39-
const BORS_AUTHOR: &str = "bors";
39+
/// Git usernames used by bors.
40+
const BORS_AUTHORS: &[&str] = &["bors", "rust-bors[bot]"];
4041

4142
#[derive(Debug, Clone, PartialEq)]
4243
pub struct Commit {
@@ -997,9 +998,9 @@ impl Config {
997998
let start = access.commit(start_sha)?;
998999
let end = access.commit(end_sha)?;
9991000
let assert_by_bors = |c: &Commit| -> anyhow::Result<()> {
1000-
if c.committer.name != BORS_AUTHOR {
1001+
if !BORS_AUTHORS.contains(&c.committer.name.as_str()) {
10011002
bail!(
1002-
"Expected author {} to be {BORS_AUTHOR} for {}.\n \
1003+
"Expected author {} to be one of {BORS_AUTHORS:?} for {}.\n \
10031004
Make sure specified commits are on the default branch \
10041005
and refer to a bors merge commit!",
10051006
c.committer.name,

0 commit comments

Comments
 (0)