Files
vesti/openspec/changes/gitea-origin-push-mirror/design.md
T

48 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Context
Gitea 1.26.2 (`gitea.nixg.ru`), репозиторий `estorozhenko/vesti` (id 53), размер 3099 КБ,
`default_branch: main`, HEAD `b754d4e5a395b75f498a48b91dd7d6b899a23c33` — совпадает с локальным.
Локально: единственный remote `origin` = gitverse.
Токены в `/opt/hermes/.hermes/secrets/git-tokens.env`: `GITEA_NIXG_TOKEN` (40, read:issue + repo),
`GITVERSE_PAT` (40) + `GITVERSE_LOGIN` (`kpa39l`).
## Точные шаги (диффы)
1. Снять mirror (API, администратор репо):
`PATCH /api/v1/repos/estorozhenko/vesti` → `{"mirror": false}`
Проверка: `GET /api/v1/repos/estorozhenko/vesti` → `"mirror": false`;
`curl -H "Authorization: token $T" .../info/refs?service=git-receive-pack` → `200` (было `403`).
2. Push-mirror в gitverse:
`POST /api/v1/repos/estorozhenko/vesti/push_mirrors`
```json
{"remote_address": "https://gitverse.ru/kpa39l/vesti.git",
"remote_username": "kpa39l",
"remote_password": "<GITVERSE_PAT>",
"sync_on_commit": true,
"interval": "8h"}
```
Проверка: `GET .../push_mirrors` → один элемент, `POST .../push_mirrors/{id}/sync` → синхронизация,
затем `git ls-remote https://gitverse.ru/kpa39l/vesti.git main` = локальный HEAD.
3. Локальный git:
```
git remote set-url origin https://gitea.nixg.ru/estorozhenko/vesti.git
git remote add gitverse https://gitverse.ru/kpa39l/vesti.git # fetch-only
git config remote.gitverse.pushurl no-push # защита от случайного пуша
git config credential.helper '!f(){ echo username=estorozhenko; echo "password=$(sed -n "s/^export\?\s*GITEA_NIXG_TOKEN=//p" /opt/hermes/.hermes/secrets/git-tokens.env | tr -d """)"; };f'
```
Токен остаётся в файле секретов, в `.git/config` — только путь к нему.
## Non-Goals
- Перевод на SSH (`гitea.nixg.ru:2222` закрыт) и на Gitea Actions-пайплайн.
- Зеркалирование wiki/issues — только код.
## Проверка (приёмка)
- `git push origin main` проходит (no-op пуш), `git ls-remote origin main` = `b754d4e`.
- `git ls-remote gitverse main` после sync = тот же SHA.
- `git push gitverse main` отвергается (no-push) — случайный пуш в зеркало невозможен.