Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 18 additions & 18 deletions src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,26 +326,26 @@ pub fn run_apply(repo_arg: Option<&str>, dry_run: bool) -> Result<()> {
sync_labels(&client, &owner, &repo_name, false)?;
println!(" ✓ Labels synced");

// 2. Branch protection (skip if already enabled, warn on failure)
if !ctx.branch_protection_enabled {
match crate::github::branches::apply_branch_protection(
&client, &owner, &repo_name, "main", "CI",
) {
Ok(()) => println!(" ✓ Branch protection applied"),
Err(e) => {
let msg = format!("{e:#}");
if msg.contains("403") {
println!(" ⚠ Branch protection skipped (403 Forbidden)");
println!(" Possible causes:");
println!(" • Private repo on a free org plan (requires GitHub Team)");
println!(" • Token not authorized for this organization");
} else {
println!(" ⚠ Branch protection failed: {msg}");
}
// 2. Branch protection (always apply to ensure correct config)
match crate::github::branches::apply_branch_protection(
&client,
&owner,
&repo_name,
"main",
"rust-ci / Format, Lint & Test",
) {
Ok(()) => println!(" ✓ Branch protection applied"),
Err(e) => {
let msg = format!("{e:#}");
if msg.contains("403") {
println!(" ⚠ Branch protection skipped (403 Forbidden)");
println!(" Possible causes:");
println!(" • Private repo on a free org plan (requires GitHub Team)");
println!(" • Token not authorized for this organization");
} else {
println!(" ⚠ Branch protection failed: {msg}");
}
}
} else {
println!(" ✓ Branch protection (already enabled)");
}

// 3. Develop branch (if needed)
Expand Down
16 changes: 14 additions & 2 deletions src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,25 @@ fn execute(client: &GithubClient, c: &WizardConfig, dry_run: bool, token: &str)
step!(
&format!("apply branch protection ({})", c.default_branch),
{
branches::apply_branch_protection(client, owner, name, &c.default_branch, "build")?;
branches::apply_branch_protection(
client,
owner,
name,
&c.default_branch,
"rust-ci / Format, Lint & Test",
)?;
Ok::<(), anyhow::Error>(())
}
);
if c.create_develop {
step!("apply branch protection (develop)", {
branches::apply_branch_protection(client, owner, name, "develop", "build")?;
branches::apply_branch_protection(
client,
owner,
name,
"develop",
"rust-ci / Format, Lint & Test",
)?;
Ok::<(), anyhow::Error>(())
});
}
Expand Down
Loading