pre-commit:
  parallel: true
  commands:
    go-fmt:
      run: go fmt ./...
    go-imports:
      run: goimports -w .
    go-lint:
      run: golangci-lint run
    go-vet:
      run: go vet ./...
    go-test:
      run: go test -v ./...

commit-msg:
  commands:
    commitlint:
      run: npx --no -- commitlint --edit $1

# Soft constraint: the GitHub plan tier blocks branch protection on this
# private repo (HTTP 403). Catch direct pushes to internal / main here so the
# normal flow stays "open a PR + GitHub UI Squash and merge".
# See doc/development-workflow-zh.md § 5 for the full soft-constraint model.
#
# Emergency bypass: `git push --no-verify`. The reason must be logged in the
# corresponding Multica issue per the development workflow doc.
pre-push:
  commands:
    block-direct-push-to-protected:
      run: |
        set -e
        while read local_ref local_sha remote_ref remote_sha; do
          case "$remote_ref" in
            refs/heads/internal|refs/heads/main)
              echo "❌ Direct push to ${remote_ref##refs/heads/} is forbidden." >&2
              echo "   Open a PR and use GitHub UI 'Squash and merge' instead." >&2
              echo "   See doc/development-workflow-zh.md § 2." >&2
              echo "   Emergency bypass: git push --no-verify (must be logged in Multica)." >&2
              exit 1
              ;;
          esac
        done

