layered-soul/skills/forgejo-operations/references/codeberg-host.md

94 lines
2.5 KiB
Markdown
Raw Normal View History

# Codeberg Host Reference
Codeberg is a Forgejo-based public git host at `codeberg.org`. Git operations are identical to self-hosted Forgejo, but the API is Forgejo, SSH key names differ, and discovery flows use `git ls-remote` instead of `gh`.
## Prerequisites
SSH key must be added at https://codeberg.org/settings/keys. Test:
```bash
ssh -T git@codeberg.org
# Expected: "Hi there, <user>! You've successfully authenticated..."
```
No `gh` CLI — use pure `git` + `ssh` for everything.
## Check What's Cloned Locally
When a project spans multiple repos, first survey what exists:
```bash
for d in /home/user/ai/*/; do
if [ -d "$d/.git" ]; then
echo "=== $d ==="
git -C "$d" remote -v
fi
done
```
## Test Remote Repo Existence
```bash
git ls-remote git@codeberg.org:OrgName/RepoName.git HEAD
```
## Clone
```bash
git clone git@codeberg.org:OrgName/RepoName.git /path/to/dest
git clone --depth 1 git@codeberg.org:OrgName/RepoName.git /path/to/dest # shallow
```
## Multi-Repo AGENTS.md Audit
After cloning, audit each repo's AGENTS.md for:
- Agent identity table present
- OS split documented (Dev host vs deploy target)
- Cross-repo section lists all repos
- Constraints match platform
**Audit technique** — scan for OS-specific terms:
```python
from pathlib import Path
terms = ['FreeBSD', 'Linux', 'bastille', 'jail', 'pkg ', 'apt', 'systemd']
for term in terms:
hits = []
for path in Path(root).rglob('*'):
if path.is_file() and '.git/' not in str(path):
try:
count = path.read_text(errors='ignore').lower().count(term.lower())
if count > 0:
hits.append((str(path.relative_to(root)), count))
except: pass
if hits:
print(f' {term}: {sum(h[1] for h in hits)} hits in {len(hits)} files')
```
## Fixing Stale Git Remotes
```bash
git remote -v
git remote remove origin-https
git remote set-url origin-https git@codeberg.org:OrgName/CorrectRepo.git
```
## Shallow Clone Fixes (Codeberg-specific)
When unshallow via SSH times out, use HTTPS fallback:
```bash
git remote set-url origin https://codeberg.org/Org/Repo.git
git fetch --unshallow origin
git remote set-url origin git@codeberg.org:Org/Repo.git # restore SSH
```
## Quick Reference
| Action | Command |
|--------|---------|
| Test SSH auth | `ssh -T git@codeberg.org` |
| Check repo exists | `git ls-remote git@codeberg.org:Org/Repo.git HEAD` |
| Clone | `git clone git@codeberg.org:Org/Repo.git` |
| Shallow clone | `git clone --depth 1 git@codeberg.org:Org/Repo.git` |