Skip to content
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

Add a branch protection option to choose required approval count #1164

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/toml-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,8 @@ ci-checks = ["CI"]
# merging into this branch require another review.
# (optional - default `false`)
dismiss-stale-review = false
# How many approvals are required for a PR to be merged.
# This option is only relevant if bors is not used.
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved
# (optional - default `1`)
required-approvals = 1
```
1 change: 1 addition & 0 deletions rust_team_data/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub struct BranchProtection {
pub pattern: String,
pub ci_checks: Vec<String>,
pub dismiss_stale_review: bool,
pub required_approvals: u32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
2 changes: 2 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,4 +733,6 @@ pub(crate) struct BranchProtection {
pub ci_checks: Vec<String>,
#[serde(default)]
pub dismiss_stale_review: bool,
#[serde(default)]
pub required_approvals: Option<u32>,
}
1 change: 1 addition & 0 deletions src/static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl<'a> Generator<'a> {
pattern: b.pattern.clone(),
ci_checks: b.ci_checks.clone(),
dismiss_stale_review: b.dismiss_stale_review,
required_approvals: b.required_approvals.unwrap_or(1),
})
.collect();
let repo = v1::Repo {
Expand Down
3 changes: 2 additions & 1 deletion tests/static-api/_expected/v1/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"ci_checks": [
"CI"
],
"dismiss_stale_review": false
"dismiss_stale_review": false,
"required_approvals": 1
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion tests/static-api/_expected/v1/repos/some_repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"ci_checks": [
"CI"
],
"dismiss_stale_review": false
"dismiss_stale_review": false,
"required_approvals": 1
}
]
}