From ff7c6b11efbdc5fa32c28261d5834a44517db370 Mon Sep 17 00:00:00 2001 From: Mustaque Ahmed Date: Tue, 23 Dec 2025 15:10:55 +0530 Subject: [PATCH] feat: create ruleset add github-actions app --- sync-team/src/github/mod.rs | 47 ++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/sync-team/src/github/mod.rs b/sync-team/src/github/mod.rs index 68ae7e287..270039ed9 100644 --- a/sync-team/src/github/mod.rs +++ b/sync-team/src/github/mod.rs @@ -15,6 +15,10 @@ pub(crate) use self::api::{GitHubApiRead, GitHubWrite, HttpClient}; static DEFAULT_DESCRIPTION: &str = "Managed by the rust-lang/team repository."; static DEFAULT_PRIVACY: TeamPrivacy = TeamPrivacy::Closed; +/// GitHub Actions integration ID +/// Verified via: https://api.github.com/repos/rust-lang/rust/commits/HEAD/check-runs +const GITHUB_ACTIONS_INTEGRATION_ID: i64 = 15368; + pub(crate) fn create_diff( github: Box, teams: Vec, @@ -940,7 +944,7 @@ pub fn construct_ruleset( .iter() .map(|context| RequiredStatusCheck { context: context.clone(), - integration_id: None, + integration_id: Some(GITHUB_ACTIONS_INTEGRATION_ID), }) .collect(), strict_required_status_checks_policy: false, @@ -966,7 +970,7 @@ pub fn construct_ruleset( api::Ruleset { id: None, - name: format!("Branch protection for {}", branch_protection.pattern), + name: format!("Ruleset for {}", branch_protection.pattern), target: RulesetTarget::Branch, source_type: RulesetSourceType::Repository, enforcement: RulesetEnforcement::Active, @@ -1639,15 +1643,20 @@ fn log_ruleset( new: Option<&api::Ruleset>, mut result: impl Write, ) -> std::fmt::Result { + let is_create = new.is_none(); + let mut logged = false; + macro_rules! log { ($str:literal, $field:expr, $new_field:expr) => { let old = $field; let new_val = $new_field; - if Some(old) != new_val { + if is_create { + writeln!(result, " {}: {:?}", $str, old)?; + logged = true; + } else if Some(old) != new_val { if let Some(n) = new_val { writeln!(result, " {}: {:?} => {:?}", $str, old, n)?; - } else { - writeln!(result, " {}: {:?}", $str, old)?; + logged = true; } } }; @@ -1790,12 +1799,23 @@ fn log_ruleset( parameters.strict_required_status_checks_policy )?; if !parameters.required_status_checks.is_empty() { - let checks: Vec<_> = parameters - .required_status_checks - .iter() - .map(|c| &c.context) - .collect(); - writeln!(result, " Checks: {:?}", checks)?; + writeln!(result, " Checks:")?; + for check in ¶meters.required_status_checks { + if let Some(integration_id) = check.integration_id { + let app_name = if integration_id == GITHUB_ACTIONS_INTEGRATION_ID { + "GitHub Actions" + } else { + "unknown app" + }; + writeln!( + result, + " - {} ({}, integration_id: {})", + check.context, app_name, integration_id + )?; + } else { + writeln!(result, " - {} (any integration)", check.context)?; + } + } } } api::RulesetRule::RequiredDeployments { parameters } => { @@ -1807,6 +1827,11 @@ fn log_ruleset( )?; } } + logged = true; + } + + if !is_create && !logged { + writeln!(result, " No changes")?; } Ok(())