Update language files
This commit is contained in:
34
README.md
34
README.md
@@ -101,3 +101,37 @@ python download_and_compare.py
|
|||||||
```
|
```
|
||||||
|
|
||||||
The script will automatically load your `.env` file for local testing.
|
The script will automatically load your `.env` file for local testing.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Git Authentication Issues
|
||||||
|
|
||||||
|
If you encounter authentication errors like "could not read Username", try these steps:
|
||||||
|
|
||||||
|
1. **Verify your `.env` file** contains all required variables:
|
||||||
|
```bash
|
||||||
|
GIT_REPO_URL=https://github.com/yourusername/yourrepo.git
|
||||||
|
GIT_USERNAME=yourusername
|
||||||
|
GIT_EMAIL=your.email@example.com
|
||||||
|
GITHUB_TOKEN=ghp_your_token_here
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Test Git configuration** in the container:
|
||||||
|
```bash
|
||||||
|
docker-compose run --rm download-compare python test_git_config.py
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Check Personal Access Token permissions**:
|
||||||
|
- Ensure the token has `repo` scope
|
||||||
|
- Verify the token hasn't expired
|
||||||
|
- Check that the token belongs to the correct GitHub account
|
||||||
|
|
||||||
|
4. **Verify repository access**:
|
||||||
|
- Ensure your GitHub account has access to the repository
|
||||||
|
- Check if the repository is private and requires authentication
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
- **"No such device or address"**: Usually means Git is trying to prompt for credentials interactively
|
||||||
|
- **"Authentication failed"**: Check your Personal Access Token and repository permissions
|
||||||
|
- **"Repository not found"**: Verify the repository URL and your access permissions
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ services:
|
|||||||
- GIT_USERNAME=${GIT_USERNAME}
|
- GIT_USERNAME=${GIT_USERNAME}
|
||||||
- GIT_EMAIL=${GIT_EMAIL}
|
- GIT_EMAIL=${GIT_EMAIL}
|
||||||
- GIT_BRANCH=${GIT_BRANCH:-main}
|
- GIT_BRANCH=${GIT_BRANCH:-main}
|
||||||
|
- GITHUB_TOKEN=${GITHUB_TOKEN}
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- .:/app
|
||||||
- ./.git:/app/.git
|
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
|
|||||||
@@ -58,13 +58,44 @@ def setup_git_repo():
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def verify_git_remote():
|
||||||
|
result = subprocess.run("git remote -v", shell=True, capture_output=True, text=True, cwd="/app")
|
||||||
|
if result.returncode != 0:
|
||||||
|
print("Error checking Git remote configuration")
|
||||||
|
return False
|
||||||
|
|
||||||
|
remote_output = result.stdout.strip()
|
||||||
|
if not remote_output:
|
||||||
|
print("No Git remote configured")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(f"Git remote configuration: {remote_output}")
|
||||||
|
return True
|
||||||
|
|
||||||
def commit_and_push_changes():
|
def commit_and_push_changes():
|
||||||
if not os.path.exists("/app/.git"):
|
if not os.path.exists("/app/.git"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if not verify_git_remote():
|
||||||
|
print("Git remote not properly configured")
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run_git_command("git add .")
|
run_git_command("git add .")
|
||||||
run_git_command("git commit -m 'Update language files'")
|
run_git_command("git commit -m 'Update language files'")
|
||||||
|
|
||||||
|
github_token = os.environ.get('GITHUB_TOKEN')
|
||||||
|
if github_token:
|
||||||
|
git_repo_url = os.environ.get('GIT_REPO_URL')
|
||||||
|
git_username = os.environ.get('GIT_USERNAME')
|
||||||
|
if git_repo_url.startswith('https://'):
|
||||||
|
auth_url = git_repo_url.replace('https://', f'https://{git_username}:{github_token}@')
|
||||||
|
print(f"Setting authenticated remote URL: {auth_url}")
|
||||||
|
run_git_command(f"git remote set-url origin {auth_url}")
|
||||||
|
|
||||||
|
print("Updated Git remote configuration:")
|
||||||
|
run_git_command("git remote -v")
|
||||||
|
|
||||||
run_git_command("git push origin HEAD")
|
run_git_command("git push origin HEAD")
|
||||||
print("Changes committed and pushed to Git repository")
|
print("Changes committed and pushed to Git repository")
|
||||||
return True
|
return True
|
||||||
|
|||||||
37
test_git_config.py
Normal file
37
test_git_config.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
def test_git_config():
|
||||||
|
print("=== Git Configuration Test ===")
|
||||||
|
print(f"Working directory: {os.getcwd()}")
|
||||||
|
print(f"Git repo exists: {os.path.exists('.git')}")
|
||||||
|
|
||||||
|
if os.path.exists('.git'):
|
||||||
|
print("\n=== Git Remote Configuration ===")
|
||||||
|
result = subprocess.run("git remote -v", shell=True, capture_output=True, text=True)
|
||||||
|
if result.returncode == 0:
|
||||||
|
print(result.stdout)
|
||||||
|
else:
|
||||||
|
print(f"Error: {result.stderr}")
|
||||||
|
|
||||||
|
print("\n=== Git Config ===")
|
||||||
|
subprocess.run("git config --list", shell=True)
|
||||||
|
|
||||||
|
print("\n=== Environment Variables ===")
|
||||||
|
git_vars = ['GIT_REPO_URL', 'GIT_USERNAME', 'GIT_EMAIL', 'GITHUB_TOKEN']
|
||||||
|
for var in git_vars:
|
||||||
|
value = os.environ.get(var)
|
||||||
|
if value:
|
||||||
|
if 'TOKEN' in var:
|
||||||
|
print(f"{var}: {value[:10]}...")
|
||||||
|
else:
|
||||||
|
print(f"{var}: {value}")
|
||||||
|
else:
|
||||||
|
print(f"{var}: Not set")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_git_config()
|
||||||
Reference in New Issue
Block a user