name: No Cursor attribution # Server-side companion to the local .githooks/commit-msg and pre-commit guards. # Fails the check if any commit pushed (or in a PR) carries Cursor attribution: # a Cursor co-author trailer, an @cursor.com email, or a "generated with Cursor" # tell, in the commit message or in the author/committer identity. on: push: pull_request: workflow_dispatch: permissions: contents: read jobs: scan: name: Scan commits runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Reject Cursor attribution env: EVENT: ${{ github.event_name }} PR_BASE: ${{ github.event.pull_request.base.sha }} PR_HEAD: ${{ github.event.pull_request.head.sha }} PUSH_BEFORE: ${{ github.event.before }} SHA: ${{ github.sha }} run: | set -euo pipefail # Resolve the set of commits to scan. if [ "$EVENT" = "pull_request" ]; then range="${PR_BASE}..${PR_HEAD}" elif [ -n "${PUSH_BEFORE:-}" ] && [ "$PUSH_BEFORE" != "0000000000000000000000000000000000000000" ]; then range="${PUSH_BEFORE}..${SHA}" else # New branch / tag push or manual run: scan just the tip commit. range="${SHA}~1..${SHA}" git rev-parse "${SHA}~1" >/dev/null 2>&1 || range="$SHA" fi echo "Scanning commit range: $range" # Emit message + author + committer for each commit, then grep. fmt='commit %H%nauthor: %an <%ae>%ncommitter: %cn <%ce>%n%B' if printf '%s' "$range" | grep -q '\.\.'; then log=$(git log --format="$fmt" "$range") else log=$(git log -1 --format="$fmt" "$range") fi pattern='cursoragent@cursor\.com|@cursor\.com|Co-authored-by:[[:space:]]*Cursor|Generated (with|by) Cursor|with help from Cursor|Powered by Cursor' if printf '%s\n' "$log" | grep -niE -- "$pattern"; then echo "::error::Cursor attribution found in the commits above. Strip it (rewrite the commits) before pushing." exit 1 fi echo "No Cursor attribution found."