diff --git a/.editorconfig b/.editorconfig index 5a85f29..f15441a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,4 +10,3 @@ indent_size = 2 [*.md] trim_trailing_whitespace = false - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e5565c2..808542b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -40,4 +40,3 @@ assignees: "" - Release or rollback urgency: ## Additional Context - diff --git a/.github/workflows/ci.yml.example b/.github/workflows/ci.yml.example index 6181a8f..5535b2e 100644 --- a/.github/workflows/ci.yml.example +++ b/.github/workflows/ci.yml.example @@ -13,4 +13,3 @@ jobs: - uses: actions/checkout@v4 # Replace with project-specific setup and validation commands. - run: echo "Configure CI for this project" - diff --git a/CHANGELOG.md b/CHANGELOG.md index 730bb6c..3fba983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- `configure-github-repository.sh` accepts `--approvals N` (use 0 for a single maintainer) and repeatable `--check NAME` for project CI jobs. +- Removed trailing blank lines that failed `git diff --cached --check` in repositories copying the template files. - Plans now pair technical decisions with a detailed execution plan: preconditions, completion contract, ordered tasks with exit conditions, validation ledger, and rollback per batch. - Added `scripts/check-pr-body.sh` and a `PR description` review job that require template sections, real Summary and Validation content, and no agent attribution lines. - PR title checks now reject CJK characters; bot-generated PRs must use conventional titles too. diff --git a/CLAUDE.md b/CLAUDE.md index 7e3cc63..42acf90 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,4 +10,3 @@ Before making changes: 4. Do not commit local config, credentials, generated logs, temporary workspaces, build artifacts, or machine-specific paths. For substantial changes, follow the Spec/Plan selection rules in `CONTRIBUTING.md`. - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d14eac3..c54cf4d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -184,7 +184,9 @@ Template files do not carry GitHub branch protection settings into every new rep ./scripts/configure-github-repository.sh --repo OWNER/REPO --apply ``` -The setup script requires a GitHub account or token with permission to edit repository settings. It protects the default branch by requiring pull requests, one approving review, fresh reviews after new pushes, linear history, resolved conversations, and the `Review` workflow checks named `repository checks`, `conventional PR title`, and `PR description`. +The setup script requires a GitHub account or token with permission to edit repository settings. It protects the default branch by requiring pull requests, one approving review (fresh after new pushes), linear history, resolved conversations, and the `Review` workflow checks named `repository checks`, `conventional PR title`, and `PR description`. + +A repository with a single maintainer cannot approve its own pull requests; pass `--approvals 0` to keep the other protections without a review requirement. Add the project's CI job names with `--check NAME` (repeatable) so they are required too. If the repository already uses a ruleset, add these checks to the ruleset instead of layering classic branch protection on top. ## Security Reports diff --git a/LICENSE b/LICENSE index 7ec08c2..bb2d20f 100644 --- a/LICENSE +++ b/LICENSE @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/SECURITY.md b/SECURITY.md index b52c99a..40c11b9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -18,4 +18,3 @@ Please include: ## Sensitive Data Do not include tokens, private keys, local credentials, internal hostnames, or personal filesystem paths in issues, pull requests, commits, logs, screenshots, or test fixtures. - diff --git a/scripts/configure-github-repository.sh b/scripts/configure-github-repository.sh index cdcaf62..6cc8ab1 100755 --- a/scripts/configure-github-repository.sh +++ b/scripts/configure-github-repository.sh @@ -4,17 +4,24 @@ set -euo pipefail apply=false repo="" branch="" +approvals=1 +extra_checks=() usage() { cat <<'USAGE' Usage: - scripts/configure-github-repository.sh [--repo OWNER/REPO] [--branch BRANCH] [--apply] + scripts/configure-github-repository.sh [--repo OWNER/REPO] [--branch BRANCH] + [--approvals N] [--check NAME]... [--apply] Configures GitHub repository defaults that cannot be inherited from template files. Defaults: --repo inferred from gh repo view - --branch inferred from the GitHub default branch when gh is available + --branch inferred from the GitHub default branch when gh is available + --approvals 1; use 0 for a repository with a single maintainer, who cannot + approve their own pull requests + --check additional required status check (repeatable), such as the + project's CI job names Without --apply, this script prints the branch protection payload and does not call GitHub. USAGE @@ -34,6 +41,14 @@ while [[ $# -gt 0 ]]; do branch="${2:-}" shift 2 ;; + --approvals) + approvals="${2:-}" + shift 2 + ;; + --check) + extra_checks+=("${2:-}") + shift 2 + ;; -h|--help) usage exit 0 @@ -68,22 +83,41 @@ if [[ -z "$branch" ]]; then fi fi -payload="$(cat <<'JSON' +if [[ ! "$approvals" =~ ^[0-9]+$ ]]; then + printf 'configure-github-repository: --approvals must be a non-negative integer\n' >&2 + exit 1 +fi +if (( approvals > 0 )); then + last_push_approval=true +else + last_push_approval=false +fi + +contexts=("repository checks" "conventional PR title" "PR description") +if (( ${#extra_checks[@]} > 0 )); then + contexts+=("${extra_checks[@]}") +fi +contexts_json="" +for context in "${contexts[@]}"; do + if [[ -z "$context" || "$context" == *'"'* || "$context" == *\\* ]]; then + printf 'configure-github-repository: invalid check name: %s\n' "$context" >&2 + exit 1 + fi + contexts_json+="${contexts_json:+, }\"${context}\"" +done + +payload="$(cat <