-
Notifications
You must be signed in to change notification settings - Fork 333
feat: add deployment branch support #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
If you are changing the data structures, please make sure that the changes are not going to break serde deserialization (adding a field is fine; removing or renaming a field isn't). If you must do a breaking change to the format, make sure to coordinate it with all the users of the cc @Urgau |
repos/rust-lang/edition-guide.toml
Outdated
| [[environments]] | ||
| name = "github-pages" | ||
| [environments.github-pages] | ||
| branches = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to avoid a common default case, if the branches array is empty, I'd remove it from the current files, and keep the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for deployment branch restrictions to repository environment configurations. It transforms the environment schema from a simple list of environment names to a map structure that can specify which branches are allowed to deploy to each environment.
Key changes:
- Schema migration from array-of-tables
[[environments]]to table-of-tables[environments.{name}]with optionalbranchesfield - New
EnvironmentDiff::Updatevariant to handle changes to existing environment branch policies - Implementation of GitHub API integration for managing deployment branch policies via separate API endpoints
Reviewed changes
Copilot reviewed 112 out of 112 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/schema.rs |
Changed environments from Vec<Environment> to HashMap<String, Environment> and replaced name field with branches: Vec<String> |
rust_team_data/src/v1.rs |
Updated public API schema to use IndexMap<String, Environment> with branches field |
src/validate.rs |
Updated validation to check environment names as HashMap keys and validate branch names are non-empty |
src/static_api.rs |
Updated static API generation to sort and collect environments from HashMap into IndexMap |
src/main.rs |
Updated environment listing to display branch restrictions when present |
sync-team/src/github/mod.rs |
Added Update variant to EnvironmentDiff and updated diff logic to detect branch policy changes |
sync-team/src/github/api/write.rs |
Added update_environment, get_environment_branch_policies, set_environment_branch_policies, and delete_environment_branch_policy methods |
sync-team/src/github/api/read.rs |
Changed repo_environments return type to HashMap<String, Environment> |
sync-team/src/github/tests/test_utils.rs |
Updated test utilities to use HashMap-based environments and added environment_with_branches helper |
sync-team/src/github/tests/mod.rs |
Updated test cases to use new environment structure |
tests/static-api/_expected/v1/repos/*.json |
Updated expected JSON output to use object {} instead of array [] for environments |
repos/rust-lang/*.toml |
Migrated all repository TOML files from [[environments]] to [environments.{name}] syntax |
repos/rust-lang/bors.toml |
Example of environment with branch restrictions: branches = ["main"] |
docs/toml-schema.md |
Updated documentation with new table-of-tables syntax and branch restrictions examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| EnvironmentDiff::Update(name, branches) => { | ||
| writeln!(f, " 🔄 Update: {name}")?; | ||
| if !branches.is_empty() { | ||
| writeln!(f, " Branches: {}", branches.join(", "))?; | ||
| } | ||
| } |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The display output for EnvironmentDiff::Update doesn't clearly communicate when branch restrictions are being removed. When updating an environment from having branch restrictions to having none (empty branches list), the output only shows "🔄 Update: {name}" without indicating that restrictions are being cleared.
Suggested improvement:
EnvironmentDiff::Update(name, branches) => {
writeln!(f, " 🔄 Update: {name}")?;
if branches.is_empty() {
writeln!(f, " Remove branch restrictions")?;
} else {
writeln!(f, " Branches: {}", branches.join(", "))?;
}
}This makes it clearer to users what configuration change is being applied.
Closes: #2132
Extends environment configuration to support specifying deployment branch restrictions, allowing teams to control which branches can deploy to each environment via a new field in the TOML schema.