6.3 KiB
Gitea Setup and Auto-Commit Documentation
Overview
This document describes the Gitea repository setup and auto-commit functionality implemented for the LightRAG project. The system includes:
- Document Download Endpoint: Clickable hyperlinks for document references in search results
- Gitea Repository: Complete version control setup with automatic commits
- Auto-Commit Script: Script to automatically commit and push changes
Repository Details
- URL: https://git.mtrcompute.com/jleu3482/railseek6
- Clone URL: http://localhost:8467/jleu3482/railseek6.git
- Credentials:
- Username:
jleu3482 - Password:
jleu1212
- Username:
- Initial Commit: "Initial commit: LightRAG project with document download and auto-commit"
Document Download Implementation
API Endpoint
Added to LightRAG-main/lightrag/api/routers/document_routes.py:
@router.get("/documents/{doc_id}/download")
async def download_document(doc_id: str):
"""
Download a document by ID.
Returns the document file for download with appropriate headers.
"""
# Implementation details...
Web UI Integration
Modified LightRAG-main/webui/index.html to make document references clickable:
- Added JavaScript to convert document filenames to clickable download links
- Each reference now includes a download button with the URL:
/api/documents/{doc_id}/download
Gitea Setup Process
1. User Registration
Created Gitea user jleu3482 with email slclabs@gmail.com and password jleu1212.
2. Repository Creation
Created repository railseek6 via Gitea API:
curl -u jleu3482:jleu1212 -X POST https://git.mtrcompute.com/api/v1/user/repos \
-H "Content-Type: application/json" \
-d '{"name": "railseek6", "description": "LightRAG project with document download and auto-commit functionality", "private": false}'
3. Local Git Configuration
git init
git config user.name "jleu3482"
git config user.email "slclabs@gmail.com"
git remote add origin http://localhost:8467/jleu3482/railseek6.git
git add -A
git commit -m "Initial commit: LightRAG project with document download and auto-commit"
git push -u origin master
Auto-Commit Script
File: auto_commit_final.py
This script provides automatic commit and push functionality for future changes.
Usage
# Basic usage (auto-generates commit message)
python auto_commit_final.py
# With custom commit message
python auto_commit_final.py "Fixed OCR processing issue"
# For major changes (recommended)
python auto_commit_final.py "Major: Implemented GPU acceleration for image classification"
Features
- Automatic Change Detection: Checks
git statusfor changes - Add All Changes: Automatically stages all modified files
- Commit with Message: Uses provided message or generates timestamp-based message
- Push to Remote: Pushes to Gitea repository
- Error Handling: Includes fallback mechanisms for push failures
- Git Configuration: Ensures proper user.name and user.email are set
Integration with Development Workflow
For major changes, run the auto-commit script:
python auto_commit_final.py "Description of major changes made"
The script will:
- Detect all changed files
- Stage them for commit
- Commit with the provided message
- Push to the Gitea repository
- Display the latest commits for verification
Testing the Complete Workflow
1. Document Download Test
- Upload a document to LightRAG
- Perform a search query
- Check that document references in results are clickable
- Click a reference to download the document
2. Auto-Commit Test
- Make a change to any file
- Run
python auto_commit_final.py "Test commit" - Verify the commit appears at: https://git.mtrcompute.com/jleu3482/railseek6
3. Repository Verification
# Check repository status
git status
# View commit history
git log --oneline -5
# Verify remote connection
git remote -v
Troubleshooting
Git Push Authentication Issues
If git push fails due to authentication:
-
Update remote URL with credentials:
git remote set-url origin http://jleu3482:jleu1212@localhost:8467/jleu3482/railseek6.git -
Or use the auto-commit script which includes credential fallback.
Gitea API Access
For programmatic access to Gitea:
import requests
response = requests.get(
"https://git.mtrcompute.com/api/v1/user/repos",
auth=("jleu3482", "jleu1212")
)
Large Repository Handling
The repository contains 42,417 files (2.6 GB). Git operations may take time:
- Initial push: ~1 minute
- Subsequent commits: Faster due to delta compression
Best Practices
Commit Messages
- Use descriptive messages that explain what changed
- Format:
"Category: Brief description" - Examples:
"Feature: Added document download endpoint""Fix: Resolved OCR timeout issue""Refactor: Optimized image classification pipeline"
When to Commit
- After implementing a new feature
- After fixing a bug
- After significant refactoring
- Before major changes that could break functionality
Repository Maintenance
- Regularly pull updates if working in team
- Use branches for experimental features
- Keep commit history clean and meaningful
Files Created/Modified
Modified Files
LightRAG-main/lightrag/api/routers/document_routes.py- Added download endpointLightRAG-main/webui/index.html- Added clickable document references
Created Scripts
auto_commit_final.py- Main auto-commit scriptregister_gitea_user.py- User registration helpercreate_gitea_repo.py- Repository creation helpertest_gitea_login.py- Login verification
Future Enhancements
- Git Hooks: Pre-commit hooks for code quality checks
- CI/CD Integration: Automated testing on push
- Branch Protection: Require reviews for main branch
- Issue Tracking: Link commits to Gitea issues
- Release Management: Tag releases for version control
Conclusion
The Gitea repository setup provides:
- Complete version control for the LightRAG project
- Clickable document download links for users
- Automated commit workflow for developers
- Centralized code management with self-hosted Gitea
All major changes to the project should now be committed using the auto-commit script to maintain a complete history of development.