docs: Add Git/Gitea setup instructions
This commit is contained in:
@@ -365,6 +365,56 @@ Vedi `publish-rats-lutris.js` nella parent folder per esempio completo con:
|
||||
- Multi-step form navigation
|
||||
- Comprehensive error handling con dumps
|
||||
|
||||
## 11. **Gestione Repository Git e Gitea**
|
||||
|
||||
### Inizializzazione Repository con Git Push a Gitea
|
||||
|
||||
Per creare un nuovo progetto e sincronizzarlo con Gitea:
|
||||
|
||||
1. **Inizializza il repository locale:**
|
||||
```bash
|
||||
git init
|
||||
```
|
||||
|
||||
2. **Crea la repository su Gitea tramite API:**
|
||||
```bash
|
||||
TOKEN="d44ab7c80e14952bcb8a573ef2d909a2dc176668" # Sostituisci con il tuo token
|
||||
REPO_NAME="playwright-form-automation" # Nome della repository
|
||||
GITEA_URL="https://git.enne2.net"
|
||||
|
||||
curl -X POST "${GITEA_URL}/api/v1/user/repos" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"name\": \"${REPO_NAME}\",
|
||||
\"description\": \"Descrizione del progetto\",
|
||||
\"private\": false,
|
||||
\"auto_init\": false
|
||||
}"
|
||||
```
|
||||
|
||||
3. **Aggiungi tutti i file al staging:**
|
||||
```bash
|
||||
git add .
|
||||
```
|
||||
|
||||
4. **Crea il commit iniziale:**
|
||||
```bash
|
||||
git commit -m "Initial commit: [descrizione breve]"
|
||||
```
|
||||
|
||||
5. **Aggiungi il remote e fai il push:**
|
||||
```bash
|
||||
git remote add origin ssh://git@git.enne2.net:222/enne2/${REPO_NAME}.git
|
||||
git push -u origin master
|
||||
```
|
||||
|
||||
### Note Importanti:
|
||||
- Assicurati che `.gitignore` sia configurato correttamente prima del commit
|
||||
- Usa SSH per il push (richiede la chiave SSH configurata)
|
||||
- Il token API serve solo per creare la repository vuota tramite API
|
||||
- Vedi il file separato `GIT_GITEA_SETUP.md` per istruzioni dettagliate
|
||||
|
||||
---
|
||||
|
||||
**Creato**: 25 ottobre 2025
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
# Guida: Inizializzazione Repository e Push a Gitea
|
||||
|
||||
## Prerequisiti
|
||||
|
||||
- Git installato e configurato
|
||||
- Token API di Gitea generato da https://git.enne2.net/user/settings/applications
|
||||
- SSH key configurata per l'accesso a Gitea
|
||||
- Accesso al terminale nella directory del progetto
|
||||
|
||||
## Passo 1: Inizializzare il Repository Locale
|
||||
|
||||
```bash
|
||||
git init
|
||||
```
|
||||
|
||||
Questo crea la cartella `.git` nella directory corrente. Il `.gitignore` deve essere già presente e configurato.
|
||||
|
||||
## Passo 2: Creare la Repository su Gitea tramite API
|
||||
|
||||
### Opzione A: Usando variabili d'ambiente (Consigliato)
|
||||
|
||||
```bash
|
||||
# Imposta le variabili
|
||||
TOKEN="d44ab7c80e14952bcb8a573ef2d909a2dc176668"
|
||||
REPO_NAME="playwright-form-automation"
|
||||
GITEA_URL="https://git.enne2.net"
|
||||
REPO_DESCRIPTION="Sistema completo per automatizzare submit di form su siti web usando Playwright"
|
||||
|
||||
# Crea la repository
|
||||
curl -X POST "${GITEA_URL}/api/v1/user/repos" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"name\": \"${REPO_NAME}\",
|
||||
\"description\": \"${REPO_DESCRIPTION}\",
|
||||
\"private\": false,
|
||||
\"auto_init\": false
|
||||
}"
|
||||
```
|
||||
|
||||
### Opzione B: Comando diretto
|
||||
|
||||
```bash
|
||||
curl -X POST "https://git.enne2.net/api/v1/user/repos" \
|
||||
-H "Authorization: token d44ab7c80e14952bcb8a573ef2d909a2dc176668" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name": "playwright-form-automation",
|
||||
"description": "Sistema per automatizzare submit di form su siti web usando Playwright",
|
||||
"private": false,
|
||||
"auto_init": false
|
||||
}'
|
||||
```
|
||||
|
||||
**Output atteso:** JSON con i dettagli della repository creata (incluso l'SSH URL)
|
||||
|
||||
### Opzione C: Creare manualmente su Gitea
|
||||
|
||||
Se preferisci:
|
||||
1. Accedi a https://git.enne2.net/
|
||||
2. Clicca su "+" → "New Repository"
|
||||
3. Inserisci il nome e fai click su "Create Repository"
|
||||
4. **Importante:** Assicurati che sia vuota (no auto-init)
|
||||
|
||||
## Passo 3: Aggiungere i File al Staging
|
||||
|
||||
```bash
|
||||
git add .
|
||||
```
|
||||
|
||||
Verifica che i file corretti siano stati aggiunti:
|
||||
|
||||
```bash
|
||||
git status
|
||||
```
|
||||
|
||||
Dovresti vedere tutti i file tranne quelli in `.gitignore` (node_modules, page-dumps ecc).
|
||||
|
||||
## Passo 4: Creare il Primo Commit
|
||||
|
||||
```bash
|
||||
git commit -m "Initial commit: Playwright form automation system"
|
||||
```
|
||||
|
||||
Oppure con descrizione più dettagliata:
|
||||
|
||||
```bash
|
||||
git commit -m "Initial commit: Playwright form automation system
|
||||
|
||||
- Page dumping system for debugging
|
||||
- Form element handling
|
||||
- Login automation with fallback
|
||||
- Comprehensive error handling"
|
||||
```
|
||||
|
||||
## Passo 5: Configurare il Remote SSH
|
||||
|
||||
```bash
|
||||
git remote add origin ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git
|
||||
```
|
||||
|
||||
Verifica che il remote sia stato aggiunto correttamente:
|
||||
|
||||
```bash
|
||||
git remote -v
|
||||
```
|
||||
|
||||
Output atteso:
|
||||
```
|
||||
origin ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git (fetch)
|
||||
origin ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git (push)
|
||||
```
|
||||
|
||||
## Passo 6: Fare il Push del Codice
|
||||
|
||||
```bash
|
||||
git push -u origin master
|
||||
```
|
||||
|
||||
**Output atteso:**
|
||||
```
|
||||
Enumerazione degli oggetti in corso: 10, fatto.
|
||||
Conteggio degli oggetti in corso: 100% (10/10), fatto.
|
||||
...
|
||||
To ssh://git@git.enne2.net:222/enne2/playwright-form-automation.git
|
||||
* [new branch] master -> master
|
||||
branch 'master' set up to track 'origin/master'.
|
||||
```
|
||||
|
||||
## Verificazione
|
||||
|
||||
1. Visita https://git.enne2.net/enne2/playwright-form-automation
|
||||
2. Verifica che i file siano visibili
|
||||
3. Controlla il log dei commit
|
||||
|
||||
## Comandi Futuri
|
||||
|
||||
### Dopo il primo push, per i commit successivi:
|
||||
|
||||
```bash
|
||||
# Effettuare modifiche ai file...
|
||||
|
||||
# Aggiungere i file modificati
|
||||
git add .
|
||||
|
||||
# Creare un commit
|
||||
git commit -m "Descrizione delle modifiche"
|
||||
|
||||
# Fare il push
|
||||
git push origin master
|
||||
```
|
||||
|
||||
### Visualizzare la cronologia:
|
||||
|
||||
```bash
|
||||
git log --oneline
|
||||
```
|
||||
|
||||
### Tirare gli ultimi cambiamenti da remoto:
|
||||
|
||||
```bash
|
||||
git pull origin master
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Errore: "SSH key not found"
|
||||
|
||||
**Soluzione:** Configura la tua SSH key:
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C "me@enne2.net"
|
||||
ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 222 git@git.enne2.net
|
||||
```
|
||||
|
||||
### Errore: "fatal: .git is not a repository"
|
||||
|
||||
**Soluzione:** Esegui `git init` nella directory corretta
|
||||
|
||||
### Errore: "remote: Repository not found"
|
||||
|
||||
**Soluzione:**
|
||||
- Verifica che la repository esista su Gitea
|
||||
- Controlla l'SSH URL (incluso il nome utente e il numero di porta 222)
|
||||
|
||||
### Errore: "Your branch and 'origin/master' have diverged"
|
||||
|
||||
**Soluzione:**
|
||||
```bash
|
||||
git pull origin master --rebase
|
||||
git push origin master
|
||||
```
|
||||
|
||||
## Variabili Comuni
|
||||
|
||||
| Variabile | Valore | Note |
|
||||
|-----------|--------|------|
|
||||
| `TOKEN` | `d44ab7c80e14952bcb8a573ef2d909a2dc176668` | Token API personale |
|
||||
| `GITEA_URL` | `https://git.enne2.net` | URL base di Gitea |
|
||||
| `SSH_HOST` | `git@git.enne2.net` | Host SSH |
|
||||
| `SSH_PORT` | `222` | Porta SSH custom |
|
||||
| `REPO_NAME` | `playwright-form-automation` | Nome della repository |
|
||||
| `USERNAME` | `enne2` | Username di Gitea |
|
||||
|
||||
## Script Automatico
|
||||
|
||||
Puoi creare uno script bash per automatizzare tutto il processo:
|
||||
|
||||
**File: `setup-gitea-repo.sh`**
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
# Variabili di configurazione
|
||||
TOKEN="d44ab7c80e14952bcb8a573ef2d909a2dc176668"
|
||||
GITEA_URL="https://git.enne2.net"
|
||||
SSH_HOST="git@git.enne2.net"
|
||||
SSH_PORT="222"
|
||||
USERNAME="enne2"
|
||||
REPO_NAME="${1:-playwright-form-automation}"
|
||||
REPO_DESC="${2:-Playwright Form Automation System}"
|
||||
|
||||
echo "📦 Inizializzazione repository: $REPO_NAME"
|
||||
|
||||
# Step 1: git init
|
||||
echo "1️⃣ Inizializzando repository locale..."
|
||||
git init
|
||||
|
||||
# Step 2: Crea repository su Gitea
|
||||
echo "2️⃣ Creando repository su Gitea..."
|
||||
RESPONSE=$(curl -s -X POST "${GITEA_URL}/api/v1/user/repos" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"name\": \"${REPO_NAME}\", \"description\": \"${REPO_DESC}\", \"private\": false, \"auto_init\": false}")
|
||||
|
||||
if echo "$RESPONSE" | grep -q "\"name\":\"${REPO_NAME}\""; then
|
||||
echo "✅ Repository creata su Gitea"
|
||||
else
|
||||
echo "❌ Errore nella creazione della repository"
|
||||
echo "$RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 3: git add
|
||||
echo "3️⃣ Aggiungendo file..."
|
||||
git add .
|
||||
|
||||
# Step 4: git commit
|
||||
echo "4️⃣ Creando commit iniziale..."
|
||||
git commit -m "Initial commit: $REPO_DESC"
|
||||
|
||||
# Step 5: git remote
|
||||
echo "5️⃣ Configurando remote SSH..."
|
||||
git remote add origin "ssh://${SSH_HOST}:${SSH_PORT}/${USERNAME}/${REPO_NAME}.git"
|
||||
|
||||
# Step 6: git push
|
||||
echo "6️⃣ Facendo push del codice..."
|
||||
git push -u origin master
|
||||
|
||||
echo "✨ Repository sincronizzata!"
|
||||
echo "📍 URL: ${GITEA_URL}/${USERNAME}/${REPO_NAME}"
|
||||
```
|
||||
|
||||
**Utilizzo:**
|
||||
```bash
|
||||
chmod +x setup-gitea-repo.sh
|
||||
./setup-gitea-repo.sh "nome-repo" "Descrizione del progetto"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Creato**: 25 ottobre 2025
|
||||
**Ultimo aggiornamento**: 25 ottobre 2025
|
||||
Reference in New Issue
Block a user