From 2e81551f844fd6c035560a36822d753023130299 Mon Sep 17 00:00:00 2001 From: Aleksey Sabilin Date: Tue, 28 Jul 2026 10:21:54 +0300 Subject: [PATCH] docs(rules): git commit via -F file when message has parentheses Document fix(ci): and special chars breaking wsl -lc one-liners. Use .tmp-commit-msg.txt + GIT_EDITOR=true git commit -F in .sh scripts. [skip ci] --- .cursor/rules/agent-pitfalls.mdc | 17 +++++++++++--- .cursor/rules/shell-wsl-not-powershell.mdc | 27 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.cursor/rules/agent-pitfalls.mdc b/.cursor/rules/agent-pitfalls.mdc index ee1bb6f..a5417f6 100644 --- a/.cursor/rules/agent-pitfalls.mdc +++ b/.cursor/rules/agent-pitfalls.mdc @@ -12,7 +12,7 @@ alwaysApply: true | Симптом | Причина | Как правильно | |---------|---------|---------------| | `unexpected EOF`, `ParserError`, пустой curl | PS ломает `"`, `$`, heredoc, `&&` | Файл `.sh` → `wsl -e bash /mnt/c/.../script.sh` | -| `bash: syntax error near '('` | `grep -E ^(...)` без кавычек в PS | Только внутри `.sh` | +| `bash: syntax error near '('` | `grep -E ^(...)` в PS; **`fix(ci):` / `(…)` в `wsl -lc` one-liner** | Только внутри `.sh`; commit → `-F` файл (см. ниже) | | `{{.Names}}: command not found` | `docker --format "{{…}}"` в PS | Формат в `.sh` или простой `docker ps` | | `&&` is not valid | PowerShell не bash | Отдельные команды или `.sh` | @@ -22,8 +22,9 @@ alwaysApply: true | Симптом | Как правильно | |---------|---------------| -| `Co-authored-by: Cursor <…>` / `<` ParserError | `git commit -F .tmp-msg.txt` из PS **или** `~/.cursor/eventhub/git-commit.sh` в WSL | | `#` в `-m` обрезает сообщение | `-F` файл; в тексте `Refs EventHub/EventHubBack#N` | +| `syntax error near '('` на commit | Сообщение `fix(ci): …` inline в `wsl -lc '… git-commit.sh … fix(ci): …'` | **Только** `.tmp-commit-msg.txt` + `git commit -F`; или `.sh` без inline `-m` | +| `Co-authored-by: Cursor <…>` / `<` ParserError | `git commit -F .tmp-msg.txt` из PS **или** `git-commit.sh` **из `.sh`**, не из PS one-liner | | `editor` / not a terminal | Не `git commit` без `-F` в WSL; из Windows: `git commit -F file` | | Сотни `M` после reset на `/mnt/c` | `git config core.filemode false` (локально); не «чинить» код | | Удалились `.cursor/`, `.idea/` | **`git clean -fdx` только с backup** env + certs; IDE-директории **не трогать** | @@ -32,7 +33,17 @@ alwaysApply: true **`git clean` / reset к origin:** сначала сохранить `docker/.env*`, `.env.development`, `docker/traefik/certs/*`. -**Push:** запрещены голые `git push` / `git push origin …`. Канон — `bash ~/.cursor/eventhub/git-push.sh ` (токен из secrets). +**Push:** запрещены голые `git push` / `git push origin …`. Канон — `bash /mnt/c/Users/alexc/.cursor/eventhub/git-push.sh ` (токен из secrets). + +**Commit (сообщение со скобками, `#`, `$`, пробелами):** не передавать subject/body аргументом через PowerShell или `wsl -e bash -lc '…'`. Пиши `.tmp-commit-msg.txt` в репо, затем в `.sh`: + +```bash +cd /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubBack +git add path/to/file +GIT_EDITOR=true git commit -F .tmp-commit-msg.txt +``` + +Запуск из PS: `wsl -e bash /mnt/c/.../EventHubBack/.tmp-commit.sh` — **без** `-lc` и **без** `-m "fix(ci): …"`. ## 3. Docker dev (Swarm локально) diff --git a/.cursor/rules/shell-wsl-not-powershell.mdc b/.cursor/rules/shell-wsl-not-powershell.mdc index d585587..34b922c 100644 --- a/.cursor/rules/shell-wsl-not-powershell.mdc +++ b/.cursor/rules/shell-wsl-not-powershell.mdc @@ -37,9 +37,28 @@ wsl -e bash -lc 'cd /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubFront && np wsl -e bash -lc ".... python -c \"import...\" ...." # ломается curl ... -d "{\"email\":\"$x\"}" # в PS ломается git commit -m "$(cat <<'EOF' ...)" # в PS не так +wsl -e bash -lc 'git-commit.sh … fix(ci): subject' # ( ) ломают bash +wsl -e bash -lc 'git commit -m "fix(ci): …"' # то же npm / npx / node из Windows # сломан ``` +### Git commit — канон (subject с `( )`, `#`, `$`) + +1. Текст коммита — в файл репо, напр. `.tmp-commit-msg.txt` (LF, без heredoc из PS). +2. Скрипт `.tmp-commit.sh`: + +```bash +#!/usr/bin/env bash +set -euo pipefail +cd /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubBack +git add path1 path2 +GIT_EDITOR=true git commit -F .tmp-commit-msg.txt +``` + +3. Из PowerShell только: `wsl -e bash /mnt/c/.../EventHubBack/.tmp-commit.sh` + +**Не** передавать сообщение аргументом в `git-commit.sh` / `-m` через `wsl -lc` — скобки в `fix(ci):` парсятся как subshell. + ## Стек → команда | Задача | Как | @@ -47,7 +66,7 @@ npm / npx / node из Windows # сломан | Front lint/build/e2e | `wsl -e bash` + `cd …/EventHubFront && npm …` | | Front перед push main | сначала `npm run test:e2e:ift` в WSL, потом `~/.cursor/eventhub/git-push-main.sh` | | Back rebar/eunit | `source scripts/wsl-dev-env.sh` в WSL | -| Git commit/push | **только** `~/.cursor/eventhub/git-commit.sh` / `git-push.sh` / `git-push-main.sh` | +| Git commit/push | **commit:** `.tmp-commit-msg.txt` + `git commit -F` в `.sh`; **push:** `bash /mnt/c/Users/alexc/.cursor/eventhub/git-push.sh …` | | JSON/API/python | скрипт `.sh` или `.py` на диске, запуск из WSL | ## Git push (обязательно) @@ -56,10 +75,12 @@ npm / npx / node из Windows # сломан **Канон:** ```text -bash ~/.cursor/eventhub/git-push.sh /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubBack -bash ~/.cursor/eventhub/git-push-main.sh /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubFront +bash /mnt/c/Users/alexc/.cursor/eventhub/git-push.sh /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubBack +bash /mnt/c/Users/alexc/.cursor/eventhub/git-push-main.sh /mnt/c/Users/alexc/IdeaProjects/eventHub/EventHubFront ``` +Путь WSL: `/mnt/c/Users/alexc/.cursor/eventhub/` (не `~/.cursor/…` — home в WSL может отличаться). + Credential store в WSL уже настроен (`credential.helper=store` + `git.sabilin.com`); хелпер всё равно предпочтителен (явный URL с токеном из secrets). ## Перед push Front