Test: Added auto-commit documentation and test file
This commit is contained in:
203
GITEA_SETUP_AND_AUTOCOMMIT.md
Normal file
203
GITEA_SETUP_AND_AUTOCOMMIT.md
Normal file
@@ -0,0 +1,203 @@
|
||||
# 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:
|
||||
|
||||
1. **Document Download Endpoint**: Clickable hyperlinks for document references in search results
|
||||
2. **Gitea Repository**: Complete version control setup with automatic commits
|
||||
3. **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`
|
||||
- **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`:
|
||||
```python
|
||||
@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:
|
||||
```bash
|
||||
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
|
||||
```bash
|
||||
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
|
||||
```bash
|
||||
# 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
|
||||
1. **Automatic Change Detection**: Checks `git status` for changes
|
||||
2. **Add All Changes**: Automatically stages all modified files
|
||||
3. **Commit with Message**: Uses provided message or generates timestamp-based message
|
||||
4. **Push to Remote**: Pushes to Gitea repository
|
||||
5. **Error Handling**: Includes fallback mechanisms for push failures
|
||||
6. **Git Configuration**: Ensures proper user.name and user.email are set
|
||||
|
||||
### Integration with Development Workflow
|
||||
|
||||
For major changes, run the auto-commit script:
|
||||
```bash
|
||||
python auto_commit_final.py "Description of major changes made"
|
||||
```
|
||||
|
||||
The script will:
|
||||
1. Detect all changed files
|
||||
2. Stage them for commit
|
||||
3. Commit with the provided message
|
||||
4. Push to the Gitea repository
|
||||
5. Display the latest commits for verification
|
||||
|
||||
## Testing the Complete Workflow
|
||||
|
||||
### 1. Document Download Test
|
||||
1. Upload a document to LightRAG
|
||||
2. Perform a search query
|
||||
3. Check that document references in results are clickable
|
||||
4. Click a reference to download the document
|
||||
|
||||
### 2. Auto-Commit Test
|
||||
1. Make a change to any file
|
||||
2. Run `python auto_commit_final.py "Test commit"`
|
||||
3. Verify the commit appears at: https://git.mtrcompute.com/jleu3482/railseek6
|
||||
|
||||
### 3. Repository Verification
|
||||
```bash
|
||||
# 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:
|
||||
1. Update remote URL with credentials:
|
||||
```bash
|
||||
git remote set-url origin http://jleu3482:jleu1212@localhost:8467/jleu3482/railseek6.git
|
||||
```
|
||||
|
||||
2. Or use the auto-commit script which includes credential fallback.
|
||||
|
||||
### Gitea API Access
|
||||
For programmatic access to Gitea:
|
||||
```python
|
||||
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
|
||||
1. `LightRAG-main/lightrag/api/routers/document_routes.py` - Added download endpoint
|
||||
2. `LightRAG-main/webui/index.html` - Added clickable document references
|
||||
|
||||
### Created Scripts
|
||||
1. `auto_commit_final.py` - Main auto-commit script
|
||||
2. `register_gitea_user.py` - User registration helper
|
||||
3. `create_gitea_repo.py` - Repository creation helper
|
||||
4. `test_gitea_login.py` - Login verification
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
1. **Git Hooks**: Pre-commit hooks for code quality checks
|
||||
2. **CI/CD Integration**: Automated testing on push
|
||||
3. **Branch Protection**: Require reviews for main branch
|
||||
4. **Issue Tracking**: Link commits to Gitea issues
|
||||
5. **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.
|
||||
Reference in New Issue
Block a user