Skip to content

Commit

Permalink
fix: Remove org-only branch protection settings
Browse files Browse the repository at this point in the history
  • Loading branch information
twelvelabs committed Oct 25, 2022
1 parent aa654a9 commit e574e64
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 48 deletions.
20 changes: 20 additions & 0 deletions .github/config/branch-protection/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"allow_force_pushes": false,
"allow_deletions": false,
"block_creations": false,
"enforce_admins": false,
"required_conversation_resolution": false,
"required_linear_history": true,
"required_pull_request_reviews": {
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 1,
"require_last_push_approval": false
},
"required_signatures": true,
"required_status_checks": {
"strict": true,
"checks": []
},
"restrictions": null
}
25 changes: 25 additions & 0 deletions .github/config/repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"allow_auto_merge": false,
"allow_merge_commit": false,
"allow_rebase_merge": false,
"allow_squash_merge": true,
"allow_update_branch": true,
"default_branch": "main",
"delete_branch_on_merge": true,
"description": "A GitHub CLI extension to manage repository settings",
"has_issues": true,
"has_projects": true,
"has_wiki": true,
"homepage": "",
"security_and_analysis": {
"advanced_security": {
"status": "enabled"
},
"secret_scanning": {
"status": "enabled"
}
},
"squash_merge_commit_message": "BLANK",
"squash_merge_commit_title": "PR_TITLE",
"web_commit_signoff_required": false
}
7 changes: 7 additions & 0 deletions .github/config/topics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"names": [
"github",
"cli",
"gh-extension"
]
}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SHELL := /bin/bash
fixtures: ## Recreate test fixtures
rm -Rf ./tests/fixtures
./gh-repo-config init --config ./tests/fixtures
cp ./tests/fixtures/branch-protection/main.json ./tests/fixtures/branch-protection/prod.json

.PHONY: format
format: ## Format source code
Expand Down
23 changes: 5 additions & 18 deletions gh-repo-config
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,22 @@ JSON_BRANCH_PROTECTION=$(
{
"allow_force_pushes": false,
"allow_deletions": false,
"block_creations": true,
"block_creations": false,
"enforce_admins": false,
"required_conversation_resolution": false,
"required_linear_history": true,
"required_pull_request_reviews": {
"dismissal_restrictions": {
"users": [],
"teams": []
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": false,
"bypass_pull_request_allowances": {
"users": [],
"teams": []
}
"required_approving_review_count": 1,
"require_last_push_approval": false
},
"required_signatures": true,
"required_status_checks": {
"strict": true,
"checks": []
},
"restrictions": {
"users": [],
"teams": []
}
"restrictions": null
}
EOL
)
Expand Down Expand Up @@ -112,9 +101,6 @@ log:api() {
}

app::apply() {
echo "APP_ENV: ${APP_ENV}"
echo "_GH: ${_GH}"

repo=$("${_GH}" repo view --json nameWithOwner --jq .nameWithOwner)

if [ -f "${APP_CONFIG}/repo.json" ]; then
Expand Down Expand Up @@ -173,6 +159,7 @@ app::help() {
echo " -c, --config <dir> Config directory [default: ${APP_CONFIG}]."
echo " -h, --help Show usage."
echo " -v, --version Show version."
echo ""
}

app::init() {
Expand Down
19 changes: 4 additions & 15 deletions tests/fixtures/branch-protection/main.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
{
"allow_force_pushes": false,
"allow_deletions": false,
"block_creations": true,
"block_creations": false,
"enforce_admins": false,
"required_conversation_resolution": false,
"required_linear_history": true,
"required_pull_request_reviews": {
"dismissal_restrictions": {
"users": [],
"teams": []
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": false,
"bypass_pull_request_allowances": {
"users": [],
"teams": []
}
"required_approving_review_count": 1,
"require_last_push_approval": false
},
"required_signatures": true,
"required_status_checks": {
"strict": true,
"checks": []
},
"restrictions": {
"users": [],
"teams": []
}
"restrictions": null
}
19 changes: 4 additions & 15 deletions tests/fixtures/branch-protection/prod.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
{
"allow_force_pushes": false,
"allow_deletions": false,
"block_creations": true,
"block_creations": false,
"enforce_admins": false,
"required_conversation_resolution": false,
"required_linear_history": true,
"required_pull_request_reviews": {
"dismissal_restrictions": {
"users": [],
"teams": []
},
"dismiss_stale_reviews": true,
"require_code_owner_reviews": true,
"required_approving_review_count": 2,
"require_last_push_approval": false,
"bypass_pull_request_allowances": {
"users": [],
"teams": []
}
"required_approving_review_count": 1,
"require_last_push_approval": false
},
"required_signatures": true,
"required_status_checks": {
"strict": true,
"checks": []
},
"restrictions": {
"users": [],
"teams": []
}
"restrictions": null
}

0 comments on commit e574e64

Please sign in to comment.