Skip to content

Commit e2cde71

Browse files
committed
Updates on assign based on review feedback.
1 parent 11767bd commit e2cde71

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/github.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,8 @@ impl GithubClient {
15221522
/// the given repo.
15231523
pub async fn is_new_contributor(&self, repo: &Repository, author: &str) -> bool {
15241524
if repo.fork {
1525-
// Forks always return 0 results.
1525+
// GitHub always returns 0 results in forked repos, so this cannot
1526+
// work for them.
15261527
return false;
15271528
}
15281529
let url = format!(

src/handlers/assign.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ use std::fmt;
3333
use tracing as log;
3434

3535
#[cfg(test)]
36-
mod tests_candidates;
37-
#[cfg(test)]
38-
mod tests_from_diff;
36+
mod tests {
37+
mod tests_candidates;
38+
mod tests_from_diff;
39+
}
3940

4041
const NEW_USER_WELCOME_MESSAGE: &str = "Thanks for the pull request, and welcome! \
4142
The Rust team is excited to review your changes, and you should hear from {who} soon.";
@@ -68,7 +69,7 @@ struct AssignData {
6869

6970
/// Input for auto-assignment when a PR is created.
7071
pub(super) struct AssignInput {
71-
diff: String,
72+
git_diff: String,
7273
}
7374

7475
/// Prepares the input when a new PR is opened.
@@ -87,15 +88,15 @@ pub(super) async fn parse_input(
8788
{
8889
return Ok(None);
8990
}
90-
let diff = match event.issue.diff(&ctx.github).await {
91+
let git_diff = match event.issue.diff(&ctx.github).await {
9192
Ok(None) => return Ok(None),
9293
Err(e) => {
9394
log::error!("failed to fetch diff: {:?}", e);
9495
return Ok(None);
9596
}
9697
Ok(Some(diff)) => diff,
9798
};
98-
Ok(Some(AssignInput { diff }))
99+
Ok(Some(AssignInput { git_diff }))
99100
}
100101

101102
/// Handles the work of setting an assignment for a new PR and posting a
@@ -161,7 +162,7 @@ pub(super) async fn handle_input(
161162
if config.warn_non_default_branch {
162163
warnings.extend(non_default_branch(event));
163164
}
164-
warnings.extend(modifies_submodule(&input.diff));
165+
warnings.extend(modifies_submodule(&input.git_diff));
165166
if !warnings.is_empty() {
166167
let warnings: Vec<_> = warnings
167168
.iter()
@@ -272,7 +273,7 @@ async fn determine_assignee(
272273
}
273274
}
274275
// Errors fall-through to try fallback group.
275-
match find_reviewers_from_diff(config, &input.diff) {
276+
match find_reviewers_from_diff(config, &input.git_diff) {
276277
Ok(candidates) if !candidates.is_empty() => {
277278
match find_reviewer_from_names(&teams, config, &event.issue, &candidates) {
278279
Ok(assignee) => return Ok((Some(assignee), false)),
@@ -378,7 +379,7 @@ fn find_reviewers_from_diff(config: &AssignConfig, diff: &str) -> anyhow::Result
378379
let max_paths = counts
379380
.iter()
380381
.filter(|(_, count)| **count == max_count)
381-
.map(|x| x.0);
382+
.map(|(path, _)| path);
382383
let mut potential: Vec<_> = max_paths
383384
.flat_map(|owner_path| &config.owners[*owner_path])
384385
.map(|owner| owner.to_string())

src/handlers/assign/tests_candidates.rs renamed to src/handlers/assign/tests/tests_candidates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tests for `candidate_reviewers_from_names`
22
3-
use super::*;
3+
use super::super::*;
44

55
/// Basic test function for testing `candidate_reviewers_from_names`.
66
fn test_from_names(

src/handlers/assign/tests_from_diff.rs renamed to src/handlers/assign/tests/tests_from_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tests for `find_reviewers_from_diff`
22
3-
use super::*;
3+
use super::super::*;
44
use crate::config::AssignConfig;
55
use std::fmt::Write;
66

0 commit comments

Comments
 (0)