Compare commits
1 Commits
3c111887d1
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| fb0d4597b5 |
@@ -1,28 +0,0 @@
|
||||
---
|
||||
description: Перед работой — прочитай все применимые rules
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Всегда читай правила
|
||||
|
||||
Перед **любой** задачей (код, git, push, релиз, ответ пользователю):
|
||||
|
||||
1. **Прочитай все применимые rules** — user rules, workspace `.cursor/rules/`, особенно с `alwaysApply: true`.
|
||||
2. **Не начинай работу**, пока не понял ограничения из rules (git, Cursor в репо, version-bump, язык ответа и т.д.).
|
||||
3. **При конфликте** запроса пользователя и rule — остановись, объясни конфликт, спроси подтверждение.
|
||||
|
||||
## Обязательные проверки по типу задачи
|
||||
|
||||
| Задача | Перед действием прочитай / проверь |
|
||||
|--------|-------------------------------------|
|
||||
| `git commit` / `push` | `no-cursor-in-repositories` — нет `.cursor/` в staged; `.gitignore` содержит `.cursor/` |
|
||||
| Push в `home` | `gitea-home-api` — сначала API, потом SSH push |
|
||||
| Bump версии | `version-bump` (+ `version-bump-rdp` / `version-bump-ssh` для агентских мониторов) |
|
||||
| Коммит | `git log -1 --format=fuller` — нет `cursoragent`, `Co-authored-by: Cursor` |
|
||||
|
||||
## Если rule нарушен
|
||||
|
||||
- **Не push**, не «доделывай быстрее».
|
||||
- Исправь (amend / filter / commit-tree), затем снова проверь лог.
|
||||
|
||||
Правила важнее скорости выполнения задачи.
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
description: Git, контекст файлов и формат ответов
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Контекст и дисциплина
|
||||
|
||||
## Git
|
||||
|
||||
- **Не** `git commit` / **не** `git push` без явной команды пользователя.
|
||||
- Перед commit: покажи `git diff --stat`, дождись подтверждения.
|
||||
- Conventional Commits: `feat:`, `fix:`, `docs:`, `refactor:`.
|
||||
|
||||
## Контекст
|
||||
|
||||
- Файлы: `@`, открытые вкладки, явные пути — не сканируй весь репо без запроса.
|
||||
- Не грузи файлы >500 строк без необходимости.
|
||||
- Локальные копии; не качай пакеты/URL без ошибки сборки или явного запроса.
|
||||
|
||||
## Ответы
|
||||
|
||||
- Язык: **русский** (если пользователь не переключился).
|
||||
- По коду — diff/фрагменты, не дублируй неизменённые блоки.
|
||||
- Без воды, но достаточно полно для понимания (не обрезай сложные ответы до одной строки).
|
||||
@@ -1,18 +0,0 @@
|
||||
---
|
||||
description: Bump версии RDP/SSH агентов — иначе ПК не обновятся
|
||||
globs: **/Login_Monitor.ps1,**/Deploy-LoginMonitor.ps1,**/Sac-Client.ps1,**/ssh-monitor,**/sac-client.sh,**/update_ssh_monitor.sh
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Версии агентских мониторов
|
||||
|
||||
Любая **существенная правка** без bump **не доедет** до компьютеров.
|
||||
|
||||
| Стек | Файлы | Поле / файл версии |
|
||||
|------|-------|-------------------|
|
||||
| RDP | `Login_Monitor.ps1`, `version.txt` | `$ScriptVersion` = `version.txt` |
|
||||
| SSH | `ssh-monitor`, `version.txt` | `SSH_MONITOR_VERSION` = `version.txt` |
|
||||
|
||||
Подробности: `version-bump-rdp.mdc`, `version-bump-ssh.mdc`.
|
||||
|
||||
**SAC backend:** `backend/app/version.py` (`APP_VERSION`) — отдельный релиз, на агенты ПК не влияет.
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
description: Краткий C# без лишних токенов в выводе
|
||||
globs: **/*.cs
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# C# — компактный вывод
|
||||
|
||||
- File-scoped namespaces, pattern matching, target-typed `new()`, primary constructors где уместно.
|
||||
- Без XML-комментариев, `#region`, лишних `using`.
|
||||
- Без `Console.WriteLine` / debug-log, если задача не про логирование.
|
||||
- Expression-bodied members, где читаемо.
|
||||
@@ -1,37 +0,0 @@
|
||||
---
|
||||
description: Gitea home — репо через API, не вручную в вебе
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Gitea home (papatramp)
|
||||
|
||||
При push в **`home`**, настройке remotes или первом заливе — **через Gitea API**. Не проси создать репо вручную при `Push to create is not enabled` / `Cannot find repository`.
|
||||
|
||||
## Пути (локально, не в git-репо)
|
||||
|
||||
| Назначение | Путь |
|
||||
|------------|------|
|
||||
| Конфиг API (секреты) | `$HOME\CursorRules\local\papatramp-gitea.conf` |
|
||||
| Remotes | `$HOME\CursorRules\scripts\Set-GitRemotes.ps1` |
|
||||
| Создать репо на home | `$HOME\CursorRules\scripts\Ensure-GiteaHomeRepo.ps1` |
|
||||
|
||||
`init-cursor` копирует в репо **только `*.mdc`**.
|
||||
|
||||
SSH **`home`**: `ssh://git@git.papatramp.lan:2222/PapaTramp/<RepoName>.git`
|
||||
|
||||
## Алгоритм
|
||||
|
||||
1. `GET {GiteaApiUrl}/api/v1/repos/PapaTramp/{RepoName}` — Basic Auth из конфига.
|
||||
2. Если **404** — `POST {GiteaApiUrl}/api/v1/user/repos` (или `.../orgs/PapaTramp/repos`), тело: `{ "name": "<RepoName>", "private": true, "auto_init": false }`.
|
||||
Или: `Ensure-GiteaHomeRepo.ps1 -RepoName <RepoName>`.
|
||||
3. `git push home <branch>` (SSH).
|
||||
|
||||
## Запрещено
|
||||
|
||||
- «Создайте репо в Gitea сами» без попытки API.
|
||||
- Коммитить `papatramp-gitea.conf`, пароли, временные скрипты с credentials.
|
||||
- HTTPS/`origin` для home вместо remote **`home`**.
|
||||
|
||||
## API недоступен
|
||||
|
||||
Сообщи, что LAN/API (`192.168.128.48:3000`) недоступен — VPN/сеть. Не отправляй в веб-интерфейс.
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
description: Не коммитить .cursor/ и IDE-файлы в git-репозитории
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Cursor не попадает в git
|
||||
|
||||
В **коммитах и tracked-файлах** запрещено добавлять артефакты Cursor как IDE/агента.
|
||||
|
||||
## Запрещено коммитить
|
||||
|
||||
| Путь | Назначение |
|
||||
|------|------------|
|
||||
| **`.cursor/`** | rules, hooks, hooks.json, settings — только локально |
|
||||
| **`.cursorignore`** | индексация IDE, не часть продукта |
|
||||
| **`AGENTS.md`**, **`CURSOR.md`** | служебные файлы IDE |
|
||||
|
||||
Не создавать `.cursor/hooks/` с auto-push/auto-commit в репозиториях проекта.
|
||||
|
||||
## Обязательно в `.gitignore` каждого репо
|
||||
|
||||
```gitignore
|
||||
.cursor/
|
||||
.cursorignore
|
||||
```
|
||||
|
||||
При работе в репозитории: если строк нет — **добавить в том же коммите**, что и код, **не** коммитить сами `.cursor/`.
|
||||
|
||||
После `init-cursor` (копирование rules в проект) — rules остаются **локально** и **не попадают** в `git add`.
|
||||
|
||||
## Перед `git commit` / `git push`
|
||||
|
||||
1. `git status` — в staged **нет** `.cursor/` и `.cursorignore`.
|
||||
2. **Не** использовать `git add -A` / `git add .` без проверки.
|
||||
3. Если `.cursor` уже в индексе: `git rm -r --cached .cursor` и `git rm --cached .cursorignore`.
|
||||
4. `git ls-files` — не должно быть путей, начинающихся с `.cursor`.
|
||||
|
||||
## Запрещено в тексте коммитов и docs
|
||||
|
||||
- Упоминания Cursor IDE, Cursor Agent, cursoragent, cursor.com, cursor.sh.
|
||||
- Trailers: Co-authored-by: Cursor, Made-with: Cursor.
|
||||
|
||||
## Разрешено (не путать с IDE)
|
||||
|
||||
- CSS cursor: pointer; poll cursor, DB cursor, Console.CursorLeft, MOEX analytics.cursor.
|
||||
|
||||
## Git / GitHub
|
||||
|
||||
- Author и committer — Andrey Lutsenko, без co-author Cursor.
|
||||
- Перед push в public: git log --format=fuller, поиск cursoragent / Co-authored-by: Cursor.
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
description: Компактный PowerShell в выводе агента
|
||||
globs: **/*.{ps1,psm1}
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# PowerShell — компактный вывод
|
||||
|
||||
- Pipeline вместо многострочных `foreach`, где читаемо.
|
||||
- Без comment-based help и лишних `Write-Host`, если не просили UI/логи.
|
||||
- Не дублируй длинные CLI-аргументы целиком — placeholder или переменная.
|
||||
- Сохраняй стиль и алиасы **существующего файла**; не навязывай `gc`/`gci` если в проекте полные имена.
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
description: Компактный Python в выводе агента
|
||||
globs: **/*.py
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Python — компактный вывод
|
||||
|
||||
- Comprehensions, ternary — где читаемо; stdlib (`pathlib`, `json`, `subprocess`) без лишних зависимостей.
|
||||
- Type hints — только если уже приняты в файле.
|
||||
- Без docstrings/комментариев «для объяснения», если не просили.
|
||||
- При правках — функция/метод, не весь файл; `# ... existing code ...` для неизменных блоков.
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
description: Bump version.txt и $ScriptVersion в RDP-login-monitor
|
||||
globs: **/Login_Monitor.ps1,**/Deploy-LoginMonitor.ps1,**/Sac-Client.ps1,**/Exchange-MailSecurity.ps1,**/Watchdog_RDP_Monitor.ps1,**/version.txt
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Bump RDP-login-monitor
|
||||
|
||||
Без bump **`Deploy-LoginMonitor.ps1` не обновит ПК** (`version.txt` vs `deployed_version.txt`).
|
||||
|
||||
## В том же коммите
|
||||
|
||||
1. `Login_Monitor.ps1` — `$ScriptVersion` (напр. `2.0.7-SAC`)
|
||||
2. `version.txt` — **та же строка**
|
||||
|
||||
Patch: `2.0.6-SAC` → `2.0.7-SAC`. Крупный релиз — minor по смыслу.
|
||||
|
||||
`Exchange-MailSecurity.ps1` — свой `$ScriptVersion`, bump только при правке этого пакета.
|
||||
|
||||
После bump — публикация на NETLOGON.
|
||||
@@ -1,18 +0,0 @@
|
||||
---
|
||||
description: Bump version.txt и SSH_MONITOR_VERSION в ssh-monitor
|
||||
globs: **/ssh-monitor,**/sac-client.sh,**/update_ssh_monitor.sh,**/version.txt
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Bump ssh-monitor
|
||||
|
||||
Без bump **`update_ssh_monitor.sh` не скопирует скрипт** (sha256).
|
||||
|
||||
## В том же коммите
|
||||
|
||||
1. `ssh-monitor` — `SSH_MONITOR_VERSION="X.Y.Z-SAC"`
|
||||
2. `version.txt` — **та же строка**
|
||||
|
||||
Patch по умолчанию. `sac-client.sh` версию не задаёт — берёт из установленного `ssh-monitor`.
|
||||
|
||||
После push: `git pull` + `update_ssh_monitor.sh` на хостах.
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
description: Patch/minor bump версии при осмысленных правках
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Bump версии
|
||||
|
||||
## Patch (обычно)
|
||||
|
||||
После осмысленного изменения — **+0.0.1** (`0.7.0` → `0.7.1`) в **том же коммите**.
|
||||
|
||||
## Minor / major
|
||||
|
||||
При заметном релизе — по смыслу (`0.6.x` → `0.7.0`). Не обязательно на каждую мелочь.
|
||||
@@ -1,65 +0,0 @@
|
||||
# Çàâèñèìîñòè è ïàêåòû
|
||||
node_modules/
|
||||
bower_components/
|
||||
jspm_packages/
|
||||
.npm/
|
||||
vendor/
|
||||
.pnpm-store/
|
||||
|
||||
# Âèðòóàëüíûå îêðóæåíèÿ (Python)
|
||||
.venv/
|
||||
venv/
|
||||
env/
|
||||
ENV/
|
||||
.env/
|
||||
|
||||
# Ñáîðêà, êýø è àðòåôàêòû
|
||||
dist/
|
||||
build/
|
||||
out/
|
||||
.next/
|
||||
.nuxt/
|
||||
.docusaurus/
|
||||
.cache/
|
||||
.sass-cache/
|
||||
.turbo/
|
||||
target/
|
||||
bin/
|
||||
obj/
|
||||
|
||||
# Ñèñòåìíûå ïàïêè IDE è ëîãè
|
||||
.git/
|
||||
.svn/
|
||||
.idea/
|
||||
.vscode/
|
||||
.cursor/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Ìåäèà, øðèôòû è òÿæåëûå áèíàðíûå ôàéëû
|
||||
*.png
|
||||
*.jpg
|
||||
*.jpeg
|
||||
*.gif
|
||||
*.svg
|
||||
*.ico
|
||||
*.mp4
|
||||
*.mp3
|
||||
*.pdf
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
*.exe
|
||||
*.dll
|
||||
*.woff
|
||||
*.woff2
|
||||
*.ttf
|
||||
*.eot
|
||||
|
||||
# Ñãåíåðèðîâàííûå ôàéëû áëîêèðîâîê (îïöèîíàëüíî, ýêîíîìÿò ìíîãî òîêåíîâ)
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
poetry.lock
|
||||
@@ -0,0 +1,21 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.ps1]
|
||||
charset = utf-8-bom
|
||||
end_of_line = crlf
|
||||
|
||||
[*.psm1]
|
||||
charset = utf-8-bom
|
||||
end_of_line = crlf
|
||||
|
||||
[*.sh]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
|
||||
[*.md]
|
||||
end_of_line = lf
|
||||
@@ -0,0 +1,13 @@
|
||||
* text=auto
|
||||
|
||||
*.ps1 text eol=crlf
|
||||
*.psm1 text eol=crlf
|
||||
*.psd1 text eol=crlf
|
||||
|
||||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
|
||||
*.md text eol=lf
|
||||
*.json text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
@@ -102,6 +102,32 @@ init-cursor --update # Mac
|
||||
|
||||
Push: `git push kalinamall`
|
||||
|
||||
## Push по remotes (важное)
|
||||
|
||||
| Remote | Как пушить | Ссылки в файлах |
|
||||
|--------|------------|-----------------|
|
||||
| `kalinamall` | `git push kalinamall main` (эталон) | git.kalinamall.ru |
|
||||
| `home` | `scripts/Push-HomeMirror.ps1` / `scripts/push-home-mirror.sh` | git.papatramp.ru |
|
||||
| `github` | `scripts/Publish-GithubOrphan.ps1` / `scripts/publish-to-github.sh` | github.com/PTah + hard sanitize |
|
||||
|
||||
Рабочее дерево и обычные коммиты всегда под **kalinamall**. На home/github — зеркала через скрипты (force). Rule: `remotes-mirror-and-sanitize.mdc` (копируется `init-cursor`).
|
||||
|
||||
---
|
||||
|
||||
## Кодировка файлов (Windows / Linux)
|
||||
|
||||
Правило **`file-encoding`** (`.cursor/rules/file-encoding.mdc`, `alwaysApply: true`):
|
||||
|
||||
| Среда | Расширения | Кодировка | Переносы |
|
||||
|-------|------------|-----------|----------|
|
||||
| Windows / PowerShell | `.ps1`, `.psm1` | UTF-8 **with BOM** | CRLF |
|
||||
| Linux / shell | `.sh` | UTF-8 **без BOM** | LF |
|
||||
| Runtime JSON/spool (PS → SAC/API) | на диске | UTF-8 **без BOM** | — |
|
||||
|
||||
В репозиториях проектов — `.editorconfig` и `.gitattributes` (шаблоны есть в этом repo).
|
||||
|
||||
После `init-cursor --update` правило попадает во все проекты.
|
||||
|
||||
---
|
||||
|
||||
## Конфиги (`local/`)
|
||||
@@ -112,3 +138,11 @@ Push: `git push kalinamall`
|
||||
| `git-user.conf` | git user.name / email |
|
||||
| `kalinamall-gitea.conf` | API kalinamall |
|
||||
| `papatramp-gitea.conf` | API home Gitea |
|
||||
|
||||
## Подключения на новом ПК
|
||||
|
||||
Если SSH/Gitea/GitHub/LAN ещё не настроены — см. rule **`machine-connectivity-bootstrap`** и `install.ps1` / `install.sh`.
|
||||
|
||||
### Cursor
|
||||
|
||||
На **всех** remotes (kalinamall, home, github) запрещены Cursor-trailers / cursoragent / Cursor IDE в коммитах и tracked-файлах. На github дополнительно hard sanitize хостов/PII.
|
||||
|
||||
+4
-3
@@ -1,4 +1,4 @@
|
||||
#Requires -Version 5.1
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Инициализация Cursor в текущем проекте; на новом ПК сначала настраивает git/SSH.
|
||||
@@ -9,7 +9,7 @@
|
||||
- затем копирует rules в текущий репозиторий и настраивает remotes
|
||||
|
||||
Первый запуск (приватный repo — через git clone, см. README):
|
||||
git clone --depth 1 ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git $HOME\CursorRules
|
||||
git clone --depth 1 ssh://git@git.papatramp.ru:2222/PapaTramp/Rules.git $HOME\CursorRules
|
||||
& $HOME\CursorRules\install.ps1
|
||||
|
||||
.EXAMPLE
|
||||
@@ -48,7 +48,7 @@ function Initialize-CursorRulesEnvironment {
|
||||
|
||||
if (-not $bootstrapRoot) {
|
||||
Write-Host 'Error: CursorRules not found. Run install.ps1 from Gitea first:' -ForegroundColor Red
|
||||
Write-Host ' git clone --depth 1 ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git $HOME\CursorRules' -ForegroundColor Yellow
|
||||
Write-Host ' git clone --depth 1 ssh://git@git.papatramp.ru:2222/PapaTramp/Rules.git $HOME\CursorRules' -ForegroundColor Yellow
|
||||
Write-Host ' & $HOME\CursorRules\install.ps1' -ForegroundColor Yellow
|
||||
return $false
|
||||
}
|
||||
@@ -164,6 +164,7 @@ function init-cursor {
|
||||
}
|
||||
|
||||
Install-CursorInCurrentProject -SkipGitRemotes:$SkipGitRemotes
|
||||
Write-Host '[i] Remotes policy: kalinamall=truth; home=Push-HomeMirror; github=Publish-GithubOrphan' -ForegroundColor DarkCyan
|
||||
Write-Host '[+] init-cursor complete' -ForegroundColor Green
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+2
-1
@@ -33,7 +33,7 @@ initialize_cursor_rules_environment() {
|
||||
rules_dest="$(get_cursor_rules_dest)"
|
||||
bootstrap_root="$(get_cursor_bootstrap_root)" || {
|
||||
echo 'Error: CursorRules not found. Run install.sh from Gitea first:' >&2
|
||||
echo ' curl -fsSL https://git.kalinamall.ru/PapaTramp/Rules/raw/branch/main/install.sh | bash' >&2
|
||||
echo ' curl -fsSL https://git.papatramp.ru/PapaTramp/Rules/raw/branch/main/install.sh | bash' >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -138,5 +138,6 @@ init-cursor() {
|
||||
else
|
||||
install_cursor_in_current_project
|
||||
fi
|
||||
echo '[i] Remotes policy: kalinamall=truth; home=Push-HomeMirror; github=Publish-GithubOrphan'
|
||||
echo '[+] init-cursor complete'
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
#Requires -Version 5.1
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Точка входа на новом ПК: clone Rules, bootstrap, init-cursor в текущем проекте.
|
||||
@@ -22,8 +22,8 @@ Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$rulesDest = Join-Path $HOME 'CursorRules'
|
||||
$httpsUrl = 'https://git.kalinamall.ru/PapaTramp/Rules.git'
|
||||
$sshUrl = 'ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git'
|
||||
$httpsUrl = 'https://git.papatramp.ru/PapaTramp/Rules.git'
|
||||
$sshUrl = 'ssh://git@git.papatramp.ru:2222/PapaTramp/Rules.git'
|
||||
|
||||
function Ensure-RulesClone {
|
||||
if (Test-Path (Join-Path $rulesDest '.git')) {
|
||||
|
||||
Executable → Regular
+2
-2
@@ -3,8 +3,8 @@
|
||||
set -euo pipefail
|
||||
|
||||
RULES_DEST="${RULES_DEST:-$HOME/CursorRules}"
|
||||
HTTPS_URL="${HTTPS_URL:-https://git.kalinamall.ru/PapaTramp/Rules.git}"
|
||||
SSH_URL="${SSH_URL:-ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git}"
|
||||
HTTPS_URL="${HTTPS_URL:-https://git.papatramp.ru/PapaTramp/Rules.git}"
|
||||
SSH_URL="${SSH_URL:-ssh://git@git.papatramp.ru:2222/PapaTramp/Rules.git}"
|
||||
SKIP_GIT_REMOTES=0
|
||||
UPDATE=0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#Requires -Version 5.1
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Настройка git на машине: user, SSH, Gitea keys, clone/update Rules.
|
||||
@@ -7,8 +7,8 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Root,
|
||||
[string]$RulesDest = '',
|
||||
[string]$CloneUrl = 'ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git',
|
||||
[string]$HttpsCloneUrl = 'https://git.kalinamall.ru/PapaTramp/Rules.git',
|
||||
[string]$CloneUrl = 'ssh://git@git.papatramp.ru:2222/PapaTramp/Rules.git',
|
||||
[string]$HttpsCloneUrl = 'https://git.papatramp.ru/PapaTramp/Rules.git',
|
||||
[switch]$SkipClone,
|
||||
[switch]$SkipProfile,
|
||||
[switch]$SkipGitSetup,
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
#Requires -Version 5.1
|
||||
# Publish kalinamall/main tree to github.com/PTah as a single orphan commit (no history).
|
||||
# Hard sanitize: internal URLs/hosts, site names, Cursor trailers/mentions.
|
||||
param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$SourceRepo = (Get-Location).Path,
|
||||
[string]$RemoteName = 'github',
|
||||
[string]$Version = '',
|
||||
[string[]]$ExcludePaths = @(),
|
||||
[hashtable]$OverlayFromGithub = @{}
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$SourceRepo = (Resolve-Path $SourceRepo).Path
|
||||
Set-Location $SourceRepo
|
||||
|
||||
$remoteUrl = (git remote get-url $RemoteName).Trim()
|
||||
if (-not $remoteUrl) { throw "remote not found: $RemoteName" }
|
||||
|
||||
$work = Join-Path $env:TEMP "gh-orphan-$([IO.Path]::GetFileName($SourceRepo))-$PID"
|
||||
if (Test-Path $work) { Remove-Item $work -Recurse -Force }
|
||||
New-Item -ItemType Directory -Path $work | Out-Null
|
||||
|
||||
$zip = Join-Path $env:TEMP "gh-archive-$PID.zip"
|
||||
if (Test-Path $zip) { Remove-Item $zip -Force }
|
||||
git archive --format=zip -o $zip main
|
||||
Expand-Archive -Path $zip -DestinationPath $work -Force
|
||||
Remove-Item $zip -Force
|
||||
|
||||
foreach ($drop in @('.cursor', '.cursorignore', 'AGENTS.md', 'CURSOR.md')) {
|
||||
$t = Join-Path $work $drop
|
||||
if (Test-Path $t) {
|
||||
Remove-Item $t -Recurse -Force
|
||||
Write-Host "exclude: $drop"
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rel in $ExcludePaths) {
|
||||
$target = Join-Path $work $rel
|
||||
if (Test-Path $target) {
|
||||
Remove-Item $target -Recurse -Force
|
||||
Write-Host "exclude: $rel"
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($entry in $OverlayFromGithub.GetEnumerator()) {
|
||||
$rel = $entry.Key
|
||||
$content = git show "${RemoteName}/main:$rel" 2>$null
|
||||
if ($LASTEXITCODE -ne 0) { throw "overlay missing on ${RemoteName}/main: $rel" }
|
||||
$out = Join-Path $work $rel
|
||||
$dir = Split-Path $out -Parent
|
||||
if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null }
|
||||
[IO.File]::WriteAllText($out, ($content -join "`n") + "`n", [Text.UTF8Encoding]::new($false))
|
||||
Write-Host "overlay: $rel"
|
||||
}
|
||||
|
||||
$textExt = @('.md', '.py', '.ts', '.vue', '.json', '.sh', '.ps1', '.yml', '.yaml', '.example', '.service', '.txt', '.html', '.css', '.kt', '.kts', '.xml', '.properties', '.gradle', '.pro')
|
||||
$replacements = @(
|
||||
@{ From = 'https://git\.kalinamall\.ru/PapaTramp/([^)/\s"''`]+)/src/branch/main/'; To = 'https://git.papatramp.ru/PapaTramp/$1/src/branch/main/' }
|
||||
@{ From = 'https://git\.kalinamall\.ru/PapaTramp/([^)/\s"''`]+)/blob/main/'; To = 'https://git.papatramp.ru/PapaTramp/$1/src/branch/main/' }
|
||||
@{ From = 'https://git\.kalinamall\.ru/PapaTramp/'; To = 'https://git.papatramp.ru/PapaTramp/' }
|
||||
@{ From = 'git\.kalinamall\.ru/PapaTramp/'; To = 'git.papatramp.ru/PapaTramp/' }
|
||||
@{ From = 'https://git\.papatramp\.ru/(PapaTramp|PTah)/'; To = 'https://git.papatramp.ru/PapaTramp/' }
|
||||
@{ From = 'git\.papatramp\.ru/(PapaTramp|PTah)/'; To = 'git.papatramp.ru/PapaTramp/' }
|
||||
@{ From = 'ssh://git@git\.kalinamall\.ru:2222/PapaTramp/'; To = 'https://git.papatramp.ru/PapaTramp/' }
|
||||
@{ From = 'ssh://git@git\.papatramp\.ru:2222/PapaTramp/'; To = 'https://git.papatramp.ru/PapaTramp/' }
|
||||
@{ From = 'sac-api\.kalinamall\.ru'; To = 'sac-api.example.com' }
|
||||
@{ From = 'sac\.kalinamall\.ru'; To = 'sac.example.com' }
|
||||
@{ From = 'ext\.kalinamall\.ru'; To = 'ext.example.com' }
|
||||
@{ From = '\*\.kalinamall\.ru'; To = '*.example.com' }
|
||||
@{ From = 'kalinamall\.ru'; To = 'example.com' }
|
||||
@{ From = 'papatramp\.lan'; To = 'example.lan' }
|
||||
@{ From = '192\.168\.\d+\.\d+'; To = '10.0.0.1' }
|
||||
@{ From = 'Co-authored-by:\s*Cursor\s*<cursoragent@cursor\.com>\s*'; To = '' }
|
||||
@{ From = 'Made-with:\s*Cursor\s*'; To = '' }
|
||||
@{ From = 'Cursor Agent'; To = '' }
|
||||
@{ From = 'Cursor IDE'; To = '' }
|
||||
@{ From = 'cursoragent@cursor\.com'; To = '' }
|
||||
@{ From = '(?i)\bpowered by cursor\b'; To = '' }
|
||||
@{ From = 'B26\\'; To = 'CONTOSO\' }
|
||||
@{ From = 'B26/'; To = 'CONTOSO/' }
|
||||
@{ From = 'K6A-DC\d'; To = 'WIN-DC01' }
|
||||
@{ From = 'UNMS Kalina'; To = 'Example Site' }
|
||||
@{ From = 'k\.khodasevich'; To = 'user1' }
|
||||
@{ From = '\bkalinamall\b'; To = 'example' }
|
||||
@{ From = '\bpapatramp\b'; To = 'jdoe' }
|
||||
)
|
||||
|
||||
Get-ChildItem -Path $work -Recurse -File | ForEach-Object {
|
||||
$ext = $_.Extension.ToLowerInvariant()
|
||||
if ($textExt -notcontains $ext -and $_.Name -notmatch '\.(example|service)$') { return }
|
||||
$content = [IO.File]::ReadAllText($_.FullName)
|
||||
$updated = $content
|
||||
foreach ($r in $replacements) {
|
||||
$updated = [regex]::Replace($updated, $r.From, $r.To)
|
||||
}
|
||||
if ($updated -ne $content) {
|
||||
[IO.File]::WriteAllText($_.FullName, $updated, [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
}
|
||||
|
||||
$forbidden = @(
|
||||
'git\.kalinamall\.ru',
|
||||
'git\.papatramp\.ru',
|
||||
'papatramp\.lan',
|
||||
'192\.168\.\d+\.\d+',
|
||||
'cursoragent@cursor\.com',
|
||||
'Co-authored-by:\s*Cursor',
|
||||
'Made-with:\s*Cursor',
|
||||
'(?i)Cursor Agent',
|
||||
'(?i)Cursor IDE',
|
||||
'(?i)powered by cursor',
|
||||
'\bkalinamall\b',
|
||||
'\bpapatramp\b',
|
||||
'K6A-DC',
|
||||
'B26\\'
|
||||
)
|
||||
$hits = 0
|
||||
Get-ChildItem -Path $work -Recurse -File | ForEach-Object {
|
||||
$ext = $_.Extension.ToLowerInvariant()
|
||||
if ($textExt -notcontains $ext -and $_.Name -notmatch '\.(example|service)$') { return }
|
||||
$content = [IO.File]::ReadAllText($_.FullName)
|
||||
foreach ($pat in $forbidden) {
|
||||
if ([regex]::IsMatch($content, $pat)) {
|
||||
$rel = $_.FullName.Substring($work.Length + 1)
|
||||
Write-Warning "FORBIDDEN '$pat' in $rel"
|
||||
$script:hits++
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($hits -gt 0) { throw "sanitization failed: $hits forbidden pattern(s)" }
|
||||
|
||||
Set-Location $work
|
||||
if (Test-Path .git) { Remove-Item .git -Recurse -Force }
|
||||
git init -b main | Out-Null
|
||||
git add -A
|
||||
$msg = if ($Version) { "chore(github): sync public mirror ($Version)" } else { 'chore(github): sync public mirror' }
|
||||
git -c user.name='PTah' -c user.email='papatramp@gmail.com' commit -m $msg
|
||||
git remote add target $remoteUrl
|
||||
git push target main --force
|
||||
Write-Host "OK -> $remoteUrl (orphan, force)"
|
||||
|
||||
Set-Location $SourceRepo
|
||||
Remove-Item $work -Recurse -Force
|
||||
@@ -0,0 +1,60 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Mirror current kalinamall/main tree to remote "home" with papatramp URLs (force).
|
||||
.DESCRIPTION
|
||||
Canonical working tree stays on kalinamall. This builds a temp orphan commit
|
||||
with git host URLs rewritten to git.papatramp.ru and force-pushes to home.
|
||||
Private content (LAN, names, secrets) is kept — unlike Publish-GithubOrphan.
|
||||
#>
|
||||
param(
|
||||
[string]$SourceRepo = (Get-Location).Path,
|
||||
[string]$Branch = 'main',
|
||||
[string]$RemoteName = 'home'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$SourceRepo = (Resolve-Path $SourceRepo).Path
|
||||
Set-Location $SourceRepo
|
||||
|
||||
$rewrite = Join-Path $PSScriptRoot 'Rewrite-GitHostUrls.ps1'
|
||||
if (-not (Test-Path $rewrite)) { throw "missing: $rewrite" }
|
||||
|
||||
$ensure = Join-Path $PSScriptRoot 'Ensure-GiteaHomeRepo.ps1'
|
||||
$repoName = Split-Path -Leaf (git rev-parse --show-toplevel)
|
||||
if (Test-Path $ensure) {
|
||||
try {
|
||||
& powershell -NoProfile -ExecutionPolicy Bypass -File $ensure -RepoName $repoName
|
||||
} catch {
|
||||
Write-Warning "Ensure-GiteaHomeRepo: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
$remoteUrl = (git remote get-url $RemoteName).Trim()
|
||||
if (-not $remoteUrl) { throw "remote not found: $RemoteName" }
|
||||
|
||||
$work = Join-Path $env:TEMP "home-mirror-$repoName-$PID"
|
||||
if (Test-Path $work) { Remove-Item $work -Recurse -Force }
|
||||
New-Item -ItemType Directory -Path $work | Out-Null
|
||||
|
||||
$zip = Join-Path $env:TEMP "home-archive-$PID.zip"
|
||||
if (Test-Path $zip) { Remove-Item $zip -Force }
|
||||
git archive --format=zip -o $zip $Branch
|
||||
Expand-Archive -Path $zip -DestinationPath $work -Force
|
||||
Remove-Item $zip -Force
|
||||
|
||||
& powershell -NoProfile -ExecutionPolicy Bypass -File $rewrite -Target home -Root $work
|
||||
|
||||
Set-Location $work
|
||||
if (Test-Path .git) { Remove-Item .git -Recurse -Force }
|
||||
git init -b main | Out-Null
|
||||
git add -A
|
||||
$sha = (git -C $SourceRepo rev-parse --short HEAD).Trim()
|
||||
$msg = "chore(home): mirror from kalinamall ($sha) with papatramp URLs"
|
||||
git -c user.name='PTah' -c user.email='papatramp@gmail.com' commit -m $msg | Out-Null
|
||||
git remote add target $remoteUrl
|
||||
git push target main --force
|
||||
Write-Host "OK -> $remoteUrl (home mirror, force)"
|
||||
|
||||
Set-Location $SourceRepo
|
||||
Remove-Item $work -Recurse -Force
|
||||
@@ -0,0 +1,91 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Rewrite cross-repo git host URLs in tracked text files for the target remote.
|
||||
.PARAMETER Target
|
||||
kalinamall | home | papatramp | github
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet('github', 'kalinamall', 'home', 'papatramp')]
|
||||
[string]$Target,
|
||||
|
||||
[string]$Root = (Get-Location).Path
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$Root = (Resolve-Path $Root).Path
|
||||
Set-Location $Root
|
||||
|
||||
if ($Target -eq 'home') { $Target = 'papatramp' }
|
||||
|
||||
switch ($Target) {
|
||||
'github' {
|
||||
$Base = 'https://github.com/PTah'
|
||||
$BlobSuffix = '/blob/main'
|
||||
}
|
||||
'kalinamall' {
|
||||
$Base = 'https://git.kalinamall.ru/PapaTramp'
|
||||
$BlobSuffix = '/src/branch/main'
|
||||
}
|
||||
'papatramp' {
|
||||
$Base = 'https://git.papatramp.ru/PapaTramp'
|
||||
$BlobSuffix = '/src/branch/main'
|
||||
}
|
||||
}
|
||||
|
||||
$BaseHost = $Base -replace '^https://', ''
|
||||
$sshTo = switch ($Target) {
|
||||
'github' { 'https://git.papatramp.ru/PapaTramp/' }
|
||||
'kalinamall' { 'ssh://git@git.papatramp.ru:2222/PapaTramp/' }
|
||||
default { 'ssh://git@git.papatramp.ru:2222/PapaTramp/' }
|
||||
}
|
||||
|
||||
$patterns = @(
|
||||
@{ From = 'https://github\.com/PTah/([^)/''"\s]+)/blob/main/'; To = "$Base/`${1}$BlobSuffix/" }
|
||||
@{ From = 'https://github\.com/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" }
|
||||
@{ From = 'https://git\.kalinamall\.ru/PapaTramp/([^)/''"\s]+)/blob/main/'; To = "$Base/`${1}$BlobSuffix/" }
|
||||
@{ From = 'https://git\.kalinamall\.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" }
|
||||
@{ From = 'https://git\.papatramp\.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" }
|
||||
@{ From = 'https://git\.papatramp\.ru/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" }
|
||||
@{ From = 'https://github\.com/PTah/'; To = "$Base/" }
|
||||
@{ From = 'https://git\.kalinamall\.ru/PapaTramp/'; To = "$Base/" }
|
||||
@{ From = 'https://git\.papatramp\.ru/PapaTramp/'; To = "$Base/" }
|
||||
@{ From = 'https://git\.papatramp\.ru/PTah/'; To = "$Base/" }
|
||||
@{ From = 'ssh://git@git\.kalinamall\.ru:2222/PapaTramp/'; To = $sshTo }
|
||||
@{ From = 'ssh://git@git\.papatramp\.ru:2222/PapaTramp/'; To = $sshTo }
|
||||
@{ From = 'github\.com/PTah/'; To = "$BaseHost/" }
|
||||
@{ From = 'git\.kalinamall\.ru/PapaTramp/'; To = "$BaseHost/" }
|
||||
@{ From = 'git\.papatramp\.ru/PapaTramp/'; To = "$BaseHost/" }
|
||||
@{ From = 'git\.papatramp\.ru/PTah/'; To = "$BaseHost/" }
|
||||
)
|
||||
|
||||
$extensions = @('*.md', '*.json', '*.service', '*.example', '*.sh', '*.ps1', '*.yml', '*.yaml', '*.txt', '*.kt', '*.kts', '*.xml', '*.html', '*.css', '*.ts', '*.vue', '*.py')
|
||||
$files = @()
|
||||
if (Test-Path (Join-Path $Root '.git')) {
|
||||
$files = @(git -C $Root ls-files $extensions 2>$null | Where-Object { $_ -and (Test-Path (Join-Path $Root $_)) })
|
||||
}
|
||||
if ($files.Count -eq 0) {
|
||||
$files = @(Get-ChildItem -Path $Root -Recurse -File -Include $extensions |
|
||||
Where-Object { $_.FullName -notmatch '\\(\.git|node_modules|\.venv|venv|dist|build)\\' } |
|
||||
ForEach-Object { $_.FullName.Substring($Root.Length).TrimStart('\', '/') })
|
||||
}
|
||||
|
||||
$n = 0
|
||||
foreach ($file in $files) {
|
||||
$path = Join-Path $Root $file
|
||||
$content = [System.IO.File]::ReadAllText($path)
|
||||
$updated = $content
|
||||
foreach ($p in $patterns) {
|
||||
$updated = [regex]::Replace($updated, $p.From, $p.To)
|
||||
}
|
||||
if ($updated -ne $content) {
|
||||
# UTF-8 BOM for .ps1 (Windows PS 5.1); otherwise UTF-8 no BOM
|
||||
$bom = ($path -match '\.(ps1|psm1)$')
|
||||
[System.IO.File]::WriteAllText($path, $updated, [System.Text.UTF8Encoding]::new($bom))
|
||||
Write-Output "updated: $file"
|
||||
$n++
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Rewrite-GitHostUrls: target=$Target base=$Base files_changed=$n"
|
||||
Executable → Regular
+2
-2
@@ -4,8 +4,8 @@ set -euo pipefail
|
||||
|
||||
ROOT="${ROOT:?ROOT is required}"
|
||||
RULES_DEST="${RULES_DEST:-$HOME/CursorRules}"
|
||||
CLONE_URL="${CLONE_URL:-ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git}"
|
||||
HTTPS_CLONE_URL="${HTTPS_CLONE_URL:-https://git.kalinamall.ru/PapaTramp/Rules.git}"
|
||||
CLONE_URL="${CLONE_URL:-ssh://git@git.papatramp.ru:2222/PapaTramp/Rules.git}"
|
||||
HTTPS_CLONE_URL="${HTTPS_CLONE_URL:-https://git.papatramp.ru/PapaTramp/Rules.git}"
|
||||
SKIP_CLONE="${SKIP_CLONE:-0}"
|
||||
SKIP_PROFILE="${SKIP_PROFILE:-0}"
|
||||
SKIP_GIT_SETUP="${SKIP_GIT_SETUP:-0}"
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# Publish current main tree to github as orphan + hard sanitize (force).
|
||||
# Usage: publish-to-github.sh [source_repo] [version]
|
||||
set -euo pipefail
|
||||
|
||||
SOURCE_REPO="${1:-$(pwd)}"
|
||||
VERSION="${2:-}"
|
||||
REMOTE_NAME="${REMOTE_NAME:-github}"
|
||||
SOURCE_REPO="$(cd "$SOURCE_REPO" && pwd)"
|
||||
cd "$SOURCE_REPO"
|
||||
|
||||
REMOTE_URL="$(git remote get-url "$REMOTE_NAME")"
|
||||
REPO_NAME="$(basename "$(git rev-parse --show-toplevel)")"
|
||||
WORK="${TMPDIR:-/tmp}/gh-orphan-${REPO_NAME}-$$"
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
git archive --format=tar main | tar -x -C "$WORK"
|
||||
rm -rf "$WORK/.cursor" "$WORK/.cursorignore" 2>/dev/null || true
|
||||
|
||||
# URL + PII + Cursor sanitize
|
||||
export LC_ALL=C
|
||||
while IFS= read -r -d '' f; do
|
||||
case "$f" in
|
||||
*.md|*.py|*.ts|*.vue|*.json|*.sh|*.ps1|*.yml|*.yaml|*.example|*.service|*.txt|*.html|*.css|*.kt|*.kts|*.xml|*.properties|*.gradle|*.pro) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
perl -i -pe '
|
||||
s#https://git\.kalinamall\.ru/PapaTramp/([^)/\s\"\x27`]+)/src/branch/main/#https://git.papatramp.ru/PapaTramp/$1/src/branch/main/#g;
|
||||
s#https://git\.kalinamall\.ru/PapaTramp/([^)/\s\"\x27`]+)/blob/main/#https://git.papatramp.ru/PapaTramp/$1/src/branch/main/#g;
|
||||
s#https://git\.kalinamall\.ru/PapaTramp/#https://git.papatramp.ru/PapaTramp/#g;
|
||||
s#git\.kalinamall\.ru/PapaTramp/#git.papatramp.ru/PapaTramp/#g;
|
||||
s#https://git\.papatramp\.ru/(PapaTramp|PTah)/#https://git.papatramp.ru/PapaTramp/#g;
|
||||
s#git\.papatramp\.ru/(PapaTramp|PTah)/#git.papatramp.ru/PapaTramp/#g;
|
||||
s#ssh://git\@git\.kalinamall\.ru:2222/PapaTramp/#https://git.papatramp.ru/PapaTramp/#g;
|
||||
s#ssh://git\@git\.papatramp\.ru:2222/PapaTramp/#https://git.papatramp.ru/PapaTramp/#g;
|
||||
s#sac-api\.kalinamall\.ru#sac-api.example.com#g;
|
||||
s#sac\.kalinamall\.ru#sac.example.com#g;
|
||||
s#ext\.kalinamall\.ru#ext.example.com#g;
|
||||
s#\*\.kalinamall\.ru#*.example.com#g;
|
||||
s#kalinamall\.ru#example.com#g;
|
||||
s#papatramp\.lan#example.lan#g;
|
||||
s#192\.168\.\d+\.\d+#10.0.0.1#g;
|
||||
s#Co-authored-by:\s*Cursor\s*<cursoragent\@cursor\.com>\s*##g;
|
||||
s#Made-with:\s*Cursor\s*##g;
|
||||
s#Cursor Agent##g;
|
||||
s#Cursor IDE##g;
|
||||
s#cursoragent\@cursor\.com##g;
|
||||
s#B26\\#CONTOSO\\#g;
|
||||
s#B26/#CONTOSO/#g;
|
||||
s#K6A-DC\d#WIN-DC01#g;
|
||||
s#UNMS Kalina#Example Site#g;
|
||||
s#k\.khodasevich#user1#g;
|
||||
s#\bkalinamall\b#example#g;
|
||||
s#\bpapatramp\b#jdoe#g;
|
||||
' "$f"
|
||||
done < <(find "$WORK" -type f -print0)
|
||||
|
||||
HITS=0
|
||||
while IFS= read -r -d '' f; do
|
||||
case "$f" in
|
||||
*.md|*.py|*.ts|*.vue|*.json|*.sh|*.ps1|*.yml|*.yaml|*.example|*.service|*.txt|*.html|*.css|*.kt|*.kts|*.xml|*.properties|*.gradle|*.pro) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
if grep -nE 'git\.kalinamall\.ru|git\.papatramp\.ru|papatramp\.lan|192\.168\.[0-9]+\.[0-9]+|cursoragent@cursor\.com|Co-authored-by:[[:space:]]*Cursor|Made-with:[[:space:]]*Cursor|\bkalinamall\b|\bpapatramp\b|K6A-DC|B26\\\\' "$f" >/dev/null 2>&1; then
|
||||
echo "FORBIDDEN in ${f#$WORK/}" >&2
|
||||
grep -nE 'git\.kalinamall\.ru|git\.papatramp\.ru|papatramp\.lan|192\.168\.[0-9]+\.[0-9]+|cursoragent@cursor\.com|Co-authored-by:[[:space:]]*Cursor|Made-with:[[:space:]]*Cursor|\bkalinamall\b|\bpapatramp\b|K6A-DC|B26\\\\' "$f" >&2 || true
|
||||
HITS=$((HITS + 1))
|
||||
fi
|
||||
done < <(find "$WORK" -type f -print0)
|
||||
|
||||
if [[ "$HITS" -gt 0 ]]; then
|
||||
echo "sanitization failed: $HITS file(s)" >&2
|
||||
rm -rf "$WORK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$WORK"
|
||||
git init -b main >/dev/null
|
||||
git add -A
|
||||
if [[ -n "$VERSION" ]]; then
|
||||
MSG="chore(github): sync public mirror ($VERSION)"
|
||||
else
|
||||
MSG='chore(github): sync public mirror'
|
||||
fi
|
||||
git -c user.name='PTah' -c user.email='papatramp@gmail.com' commit -m "$MSG" >/dev/null
|
||||
git remote add target "$REMOTE_URL"
|
||||
git push target main --force
|
||||
echo "OK -> $REMOTE_URL (orphan, force)"
|
||||
|
||||
cd "$SOURCE_REPO"
|
||||
rm -rf "$WORK"
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Mirror kalinamall/main to remote "home" with papatramp URLs (force).
|
||||
set -euo pipefail
|
||||
|
||||
SOURCE_REPO="${1:-$(pwd)}"
|
||||
BRANCH="${2:-main}"
|
||||
REMOTE_NAME="${3:-home}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REWRITE="$SCRIPT_DIR/rewrite-git-host-urls.sh"
|
||||
SOURCE_REPO="$(cd "$SOURCE_REPO" && pwd)"
|
||||
cd "$SOURCE_REPO"
|
||||
|
||||
REPO_NAME="$(basename "$(git rev-parse --show-toplevel)")"
|
||||
REMOTE_URL="$(git remote get-url "$REMOTE_NAME")"
|
||||
WORK="${TMPDIR:-/tmp}/home-mirror-${REPO_NAME}-$$"
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
git archive --format=tar "$BRANCH" | tar -x -C "$WORK"
|
||||
bash "$REWRITE" home "$WORK"
|
||||
|
||||
cd "$WORK"
|
||||
git init -b main >/dev/null
|
||||
git add -A
|
||||
SHA="$(git -C "$SOURCE_REPO" rev-parse --short HEAD)"
|
||||
git -c user.name='PTah' -c user.email='papatramp@gmail.com' \
|
||||
commit -m "chore(home): mirror from kalinamall ($SHA) with papatramp URLs" >/dev/null
|
||||
git remote add target "$REMOTE_URL"
|
||||
git push target main --force
|
||||
echo "OK -> $REMOTE_URL (home mirror, force)"
|
||||
|
||||
cd "$SOURCE_REPO"
|
||||
rm -rf "$WORK"
|
||||
Executable → Regular
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
# Rewrite cross-repo git host URLs in tracked text files.
|
||||
# Usage: rewrite-git-host-urls.sh github|kalinamall|home|papatramp [root]
|
||||
set -euo pipefail
|
||||
|
||||
TARGET="${1:-}"
|
||||
ROOT="${2:-$(pwd)}"
|
||||
if [[ -z "$TARGET" ]]; then
|
||||
echo "Usage: $0 github|kalinamall|home|papatramp [root]" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$TARGET" == "home" ]]; then TARGET=papatramp; fi
|
||||
ROOT="$(cd "$ROOT" && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
case "$TARGET" in
|
||||
github)
|
||||
BASE='https://github.com/PTah'
|
||||
BLOB='/blob/main'
|
||||
SSHTO='https://git.papatramp.ru/PapaTramp/'
|
||||
;;
|
||||
kalinamall)
|
||||
BASE='https://git.kalinamall.ru/PapaTramp'
|
||||
BLOB='/src/branch/main'
|
||||
SSHTO='ssh://git@git.papatramp.ru:2222/PapaTramp/'
|
||||
;;
|
||||
papatramp)
|
||||
BASE='https://git.papatramp.ru/PapaTramp'
|
||||
BLOB='/src/branch/main'
|
||||
SSHTO='ssh://git@git.papatramp.ru:2222/PapaTramp/'
|
||||
;;
|
||||
*)
|
||||
echo "Unknown target: $TARGET" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
BASE_HOST="${BASE#https://}"
|
||||
N=0
|
||||
|
||||
export BASE BLOB SSHTO BASE_HOST
|
||||
|
||||
rewrite_file() {
|
||||
local f="$1"
|
||||
local tmp
|
||||
tmp="$(mktemp)"
|
||||
perl -pe '
|
||||
s#https://github\.com/PTah/([^)/\x27\"\s]+)/blob/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
|
||||
s#https://github\.com/PTah/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
|
||||
s#https://git\.kalinamall\.ru/PapaTramp/([^)/\x27\"\s]+)/blob/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
|
||||
s#https://git\.kalinamall\.ru/PapaTramp/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
|
||||
s#https://git\.papatramp\.ru/PapaTramp/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
|
||||
s#https://git\.papatramp\.ru/PTah/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
|
||||
s#https://github\.com/PTah/#$ENV{BASE}/#g;
|
||||
s#https://git\.kalinamall\.ru/PapaTramp/#$ENV{BASE}/#g;
|
||||
s#https://git\.papatramp\.ru/PapaTramp/#$ENV{BASE}/#g;
|
||||
s#https://git\.papatramp\.ru/PTah/#$ENV{BASE}/#g;
|
||||
s#ssh://git\@git\.kalinamall\.ru:2222/PapaTramp/#$ENV{SSHTO}#g;
|
||||
s#ssh://git\@git\.papatramp\.ru:2222/PapaTramp/#$ENV{SSHTO}#g;
|
||||
s#github\.com/PTah/#$ENV{BASE_HOST}/#g;
|
||||
s#git\.kalinamall\.ru/PapaTramp/#$ENV{BASE_HOST}/#g;
|
||||
s#git\.papatramp\.ru/PapaTramp/#$ENV{BASE_HOST}/#g;
|
||||
s#git\.papatramp\.ru/PTah/#$ENV{BASE_HOST}/#g;
|
||||
' "$f" > "$tmp"
|
||||
if ! cmp -s "$f" "$tmp"; then
|
||||
mv "$tmp" "$f"
|
||||
echo "updated: $f"
|
||||
N=$((N + 1))
|
||||
else
|
||||
rm -f "$tmp"
|
||||
fi
|
||||
}
|
||||
|
||||
mapfile -t FILES < <(git -C "$ROOT" ls-files '*.md' '*.json' '*.service' '*.example' '*.sh' '*.ps1' '*.yml' '*.yaml' '*.txt' '*.kt' '*.kts' '*.xml' '*.html' '*.css' '*.ts' '*.vue' '*.py' 2>/dev/null || true)
|
||||
if [[ ${#FILES[@]} -eq 0 ]]; then
|
||||
mapfile -t FILES < <(find "$ROOT" -type f \( -name '*.md' -o -name '*.ps1' -o -name '*.sh' -o -name '*.yml' -o -name '*.yaml' -o -name '*.json' -o -name '*.txt' \) ! -path '*/.git/*' ! -path '*/node_modules/*' || true)
|
||||
fi
|
||||
|
||||
for f in "${FILES[@]}"; do
|
||||
[[ -f "$f" ]] || f="$ROOT/$f"
|
||||
[[ -f "$f" ]] || continue
|
||||
rewrite_file "$f"
|
||||
done
|
||||
|
||||
echo "Rewrite-GitHostUrls: target=$TARGET base=$BASE files_changed=$N"
|
||||
Reference in New Issue
Block a user