浏览代码

Rename config fields based on review feedback.

Eric Huss 2 年之前
父节点
当前提交
11767bddf3
共有 3 个文件被更改,包括 16 次插入16 次删除
  1. 4 4
      src/config.rs
  2. 3 3
      src/handlers/assign.rs
  3. 9 9
      src/handlers/assign/tests_candidates.rs

+ 4 - 4
src/config.rs

@@ -78,12 +78,12 @@ pub(crate) struct AssignConfig {
     /// If `true`, then posts a warning comment if the PR is opened against a
     /// different branch than the default (usually master or main).
     #[serde(default)]
-    pub(crate) non_default_branch: bool,
+    pub(crate) warn_non_default_branch: bool,
     /// A URL to include in the welcome message.
     pub(crate) contributing_url: Option<String>,
     /// Ad-hoc groups that can be referred to in `owners`.
     #[serde(default)]
-    pub(crate) groups: HashMap<String, Vec<String>>,
+    pub(crate) adhoc_groups: HashMap<String, Vec<String>>,
     /// Users to assign when a new PR is opened.
     /// The key is a gitignore-style path, and the value is a list of
     /// usernames, team names, or ad-hoc groups.
@@ -367,9 +367,9 @@ mod tests {
                     allow_unauthenticated: vec!["C-*".into()],
                 }),
                 assign: Some(AssignConfig {
-                    non_default_branch: false,
+                    warn_non_default_branch: false,
                     contributing_url: None,
-                    groups: HashMap::new(),
+                    adhoc_groups: HashMap::new(),
                     owners: HashMap::new(),
                 }),
                 note: Some(NoteConfig { _empty: () }),

+ 3 - 3
src/handlers/assign.rs

@@ -158,7 +158,7 @@ pub(super) async fn handle_input(
 
     // Compute some warning messages to post to new PRs.
     let mut warnings = Vec::new();
-    if config.non_default_branch {
+    if config.warn_non_default_branch {
         warnings.extend(non_default_branch(event));
     }
     warnings.extend(modifies_submodule(&input.diff));
@@ -297,7 +297,7 @@ async fn determine_assignee(
         }
     }
 
-    if let Some(fallback) = config.groups.get("fallback") {
+    if let Some(fallback) = config.adhoc_groups.get("fallback") {
         match find_reviewer_from_names(&teams, config, &event.issue, fallback) {
             Ok(assignee) => return Ok((Some(assignee), false)),
             Err(e) => {
@@ -638,7 +638,7 @@ fn candidate_reviewers_from_names<'a>(
         let maybe_group = group_or_user
             .strip_prefix(&org_prefix)
             .unwrap_or(group_or_user);
-        if let Some(group_members) = config.groups.get(maybe_group) {
+        if let Some(group_members) = config.adhoc_groups.get(maybe_group) {
             // If a group has already been expanded, don't expand it again.
             if seen.insert(maybe_group) {
                 group_expansion.extend(

+ 9 - 9
src/handlers/assign/tests_candidates.rs

@@ -72,7 +72,7 @@ fn generic_issue(author: &str, repo: &str) -> serde_json::Value {
 fn circular_groups() {
     // A cycle in the groups map.
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["other"]
         other = ["compiler"]
     );
@@ -84,7 +84,7 @@ fn circular_groups() {
 fn nested_groups() {
     // Test choosing a reviewer from group with nested groups.
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         a = ["@pnkfelix"]
         b = ["@nrc"]
         c = ["a", "b"]
@@ -97,7 +97,7 @@ fn nested_groups() {
 fn candidate_filtered_author_only_candidate() {
     // When the author is the only candidate.
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["nikomatsakis"]
     );
     let issue = generic_issue("nikomatsakis", "rust-lang/rust");
@@ -108,7 +108,7 @@ fn candidate_filtered_author_only_candidate() {
 fn candidate_filtered_author() {
     // Filter out the author from the candidates.
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["user1", "user2", "user3", "group2"]
         group2 = ["user2", "user4"]
     );
@@ -126,7 +126,7 @@ fn candidate_filtered_author() {
 fn candidate_filtered_assignee() {
     // Filter out an existing assignee from the candidates.
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["user1", "user2", "user3", "user4"]
     );
     let mut issue = generic_issue("user2", "rust-lang/rust");
@@ -145,7 +145,7 @@ fn groups_teams_users() {
         team2 = ["t-user2"]
     );
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         group1 = ["user1", "rust-lang/team2"]
     );
     let issue = generic_issue("octocat", "rust-lang/rust");
@@ -163,7 +163,7 @@ fn group_team_user_precedence() {
     // How it handles ambiguity when names overlap.
     let teams = toml::toml!(compiler = ["t-user1"]);
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["user2"]
     );
     let issue = generic_issue("octocat", "rust-lang/rust");
@@ -188,7 +188,7 @@ fn what_do_slashes_mean() {
     // How slashed names are handled.
     let teams = toml::toml!(compiler = ["t-user1"]);
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["user2"]
         "foo/bar" = ["foo-user"]
     );
@@ -222,7 +222,7 @@ fn what_do_slashes_mean() {
 fn invalid_org_doesnt_match() {
     let teams = toml::toml!(compiler = ["t-user1"]);
     let config = toml::toml!(
-        [groups]
+        [adhoc_groups]
         compiler = ["user2"]
     );
     let issue = generic_issue("octocat", "rust-lang/rust");