feat: Implement automatic git repository configuration detection for Gitea
Some checks failed
Test Suite / unit-tests (3.11) (push) Has been cancelled
Test Suite / unit-tests (3.12) (push) Has been cancelled
Test Suite / integration-tests (push) Has been cancelled
Test Suite / e2e-tests (push) Has been cancelled
Test Suite / performance-tests (push) Has been cancelled
Test Suite / code-quality (push) Has been cancelled
Test Suite / security-scan (push) Has been cancelled
Test Suite / test-summary (push) Has been cancelled

- Add GiteaConfig.from_git_repository() method for auto-detection
- Support HTTP(S) and SSH git remote URL formats
- Parse gitea_url, repo_owner, repo_name from git remote origin
- Only requires GITEA_API_TOKEN environment variable
- Update GiteaClient to use auto-detection as primary method
- Maintain backward compatibility with environment variables
- Fix issue creation API to use label IDs instead of names
- Add comprehensive error handling and validation
- Successfully tested with issues #33 and #34

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-28 23:27:13 +02:00
parent ad355f970c
commit ad25b2a7d7
4 changed files with 221 additions and 6 deletions

View File

@@ -170,10 +170,14 @@ class GiteaClient:
"""Initialize Gitea client.
Args:
config: GiteaConfig instance. If None, loads from environment.
config: GiteaConfig instance. If None, auto-detects from git repository.
"""
if config is None:
config = GiteaConfig.from_environment()
try:
config = GiteaConfig.from_git_repository()
except Exception:
# Fallback to environment-based config if git detection fails
config = GiteaConfig.from_environment()
config.validate()
self.config = config