diff --git a/README.md b/README.md index 24c9347..25c436a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Use this template when creating a new project that should have consistent contri ./scripts/install-git-hooks.sh ``` -6. Enable or replace the stack-specific CI example in `.github/workflows/ci.yml.example`. +6. Replace `.github/workflows/ci.yml.example` with a real `.github/workflows/ci.yml` for the project stack; the repository check accepts either file. 7. Keep `.github/workflows/review.yml` enabled for generic review checks. 8. Configure GitHub repository protection after the new repository is created: diff --git a/scripts/check-repository.sh b/scripts/check-repository.sh index ccf5cf7..e8fb69b 100755 --- a/scripts/check-repository.sh +++ b/scripts/check-repository.sh @@ -56,7 +56,8 @@ required_files=( ".github/ISSUE_TEMPLATE/bug_report.md" ".github/ISSUE_TEMPLATE/feature_request.md" ".github/workflows/review.yml" - ".github/workflows/ci.yml.example" + # Alternatives separated by "|": a project replaces the example with its real CI. + ".github/workflows/ci.yml|.github/workflows/ci.yml.example" ".gitlab/merge_request_templates/default.md" ".githooks/pre-commit" "scripts/check-pr-body.sh" @@ -69,14 +70,26 @@ required_files=( "docs/plans/0000-template.md" ) -missing=() -for file in "${required_files[@]}"; do +file_present() { if [[ "$staged" == true ]]; then - if ! git cat-file -e ":$file" 2>/dev/null; then - missing+=("$file") + git cat-file -e ":$1" 2>/dev/null + else + [[ -f "$1" ]] + fi +} + +missing=() +for entry in "${required_files[@]}"; do + found=false + IFS='|' read -r -a alternatives <<<"$entry" + for file in "${alternatives[@]}"; do + if file_present "$file"; then + found=true + break fi - elif [[ ! -f "$file" ]]; then - missing+=("$file") + done + if [[ "$found" == false ]]; then + missing+=("${entry//|/ or }") fi done