fix: detect project directory correctly for git remote parsing #71

Merged
lmiranda merged 1 commits from fix/project-directory-detection into development 2026-01-21 21:38:24 +00:00
Owner

Summary

Fixes #70 - MCP tools require explicit repo format

Root Cause

The MCP server runs with cwd set to the plugin directory (${CLAUDE_PLUGIN_ROOT}/mcp-servers/gitea), not the users project directory. This caused git remote auto-detection to fail.

Fix

Added _find_project_directory() method with multiple detection strategies:

  1. CLAUDE_PROJECT_DIR - Environment variable (if Claude Code sets this)
  2. PWD - Original working directory (if it has .git or .env)
  3. cwd - Current directory (fallback for tests and direct execution)

Tests

Added 3 new tests:

  • test_find_project_directory_from_env
  • test_find_project_directory_from_cwd
  • test_find_project_directory_none_when_no_markers

All 9 config tests passing.

Fixes #70

## Summary Fixes #70 - MCP tools require explicit repo format ### Root Cause The MCP server runs with `cwd` set to the plugin directory (`${CLAUDE_PLUGIN_ROOT}/mcp-servers/gitea`), not the users project directory. This caused git remote auto-detection to fail. ### Fix Added `_find_project_directory()` method with multiple detection strategies: 1. **CLAUDE_PROJECT_DIR** - Environment variable (if Claude Code sets this) 2. **PWD** - Original working directory (if it has `.git` or `.env`) 3. **cwd** - Current directory (fallback for tests and direct execution) ### Tests Added 3 new tests: - `test_find_project_directory_from_env` - `test_find_project_directory_from_cwd` - `test_find_project_directory_none_when_no_markers` **All 9 config tests passing.** Fixes #70
lmiranda added 1 commit 2026-01-21 21:38:02 +00:00
The MCP server runs with cwd set to the plugin directory, not the
user's project directory. This caused git remote auto-detection to
fail because it was looking at the wrong directory.

Changes:
- Added _find_project_directory() method with multiple strategies:
  1. CLAUDE_PROJECT_DIR environment variable
  2. PWD environment variable (if it has .git or .env)
  3. Current working directory (if it has .git or .env)
- Updated _detect_repo_from_git() to accept project_dir parameter
- Added 3 new tests for project directory detection

Fixes #70

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
lmiranda merged commit 4f3560d121 into development 2026-01-21 21:38:24 +00:00
lmiranda deleted branch fix/project-directory-detection 2026-01-21 21:38:24 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: personal-projects/leo-claude-mktplace#71