feat: simplify git mounts to use direct URLs instead of repo references
- Change git mount schema from repo_id to remote_url - Remove database lookups for git mount resolution - Clone directly from URL at instance startup - Simplify frontend UI to text input for Git URL - Fix route ordering in git_repositories.py to prevent 422 errors - Update all tests to use remote_url field Breaking change: Git mounts now use remote_url instead of repo_id
This commit is contained in:
@@ -333,7 +333,7 @@ class TestConfigProfilesAPI:
|
||||
"files": {},
|
||||
"git_mounts": [
|
||||
{
|
||||
"repo_id": repo_id,
|
||||
"remote_url": "https://github.com/user/repo.git",
|
||||
"source_path": ".",
|
||||
"target_path": "/app",
|
||||
"branch": "main",
|
||||
@@ -369,7 +369,7 @@ class TestConfigProfilesAPI:
|
||||
json={
|
||||
"git_mounts": [
|
||||
{
|
||||
"repo_id": repo_id,
|
||||
"remote_url": "https://github.com/user/repo.git",
|
||||
"source_path": "config",
|
||||
"target_path": "/config",
|
||||
}
|
||||
@@ -393,7 +393,7 @@ class TestConfigProfilesAPI:
|
||||
"files": {},
|
||||
"git_mounts": [
|
||||
{
|
||||
"repo_id": repo_id,
|
||||
"remote_url": "https://github.com/user/repo.git",
|
||||
"source_path": "/absolute/path",
|
||||
"target_path": "/app",
|
||||
}
|
||||
@@ -414,7 +414,7 @@ class TestConfigProfilesAPI:
|
||||
"files": {},
|
||||
"git_mounts": [
|
||||
{
|
||||
"repo_id": repo_id,
|
||||
"remote_url": "https://github.com/user/repo.git",
|
||||
"source_path": ".",
|
||||
"target_path": "relative/path",
|
||||
}
|
||||
@@ -436,7 +436,7 @@ class TestConfigProfilesAPI:
|
||||
"files": {},
|
||||
"git_mounts": [
|
||||
{
|
||||
"repo_id": repo_id,
|
||||
"remote_url": "https://github.com/user/repo.git",
|
||||
"source_path": ".",
|
||||
"target_path": "/app",
|
||||
}
|
||||
@@ -450,4 +450,4 @@ class TestConfigProfilesAPI:
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert len(data["git_mounts"]) == 1
|
||||
assert data["git_mounts"][0]["repo_id"] == repo_id
|
||||
assert data["git_mounts"][0]["remote_url"] == "https://github.com/user/repo.git"
|
||||
|
||||
@@ -102,18 +102,18 @@ class TestMergeFunctions:
|
||||
"""Test basic git mount merging."""
|
||||
result = _merge_git_mounts(
|
||||
[],
|
||||
[{"repo_id": "repo1", "source_path": ".", "target_path": "/app"}],
|
||||
[{"remote_url": "https://github.com/user/repo1.git", "source_path": ".", "target_path": "/app"}],
|
||||
"source",
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0]["repo_id"] == "repo1"
|
||||
assert result[0]["remote_url"] == "https://github.com/user/repo1.git"
|
||||
assert result[0]["target_path"] == "/app"
|
||||
|
||||
def test_merge_git_mounts_override_same_repo_target(self) -> None:
|
||||
"""Test that git mounts with same repo+target override."""
|
||||
result = _merge_git_mounts(
|
||||
[{"repo_id": "repo1", "source_path": ".", "target_path": "/app", "branch": "main"}],
|
||||
[{"repo_id": "repo1", "source_path": "src", "target_path": "/app", "branch": "dev"}],
|
||||
[{"remote_url": "https://github.com/user/repo1.git", "source_path": ".", "target_path": "/app", "branch": "main"}],
|
||||
[{"remote_url": "https://github.com/user/repo1.git", "source_path": "src", "target_path": "/app", "branch": "dev"}],
|
||||
"source",
|
||||
)
|
||||
assert len(result) == 1
|
||||
@@ -123,8 +123,8 @@ class TestMergeFunctions:
|
||||
def test_merge_git_mounts_different_targets(self) -> None:
|
||||
"""Test that git mounts with different targets are preserved."""
|
||||
result = _merge_git_mounts(
|
||||
[{"repo_id": "repo1", "source_path": ".", "target_path": "/app"}],
|
||||
[{"repo_id": "repo2", "source_path": ".", "target_path": "/config"}],
|
||||
[{"remote_url": "https://github.com/user/repo1.git", "source_path": ".", "target_path": "/app"}],
|
||||
[{"remote_url": "https://github.com/user/repo2.git", "source_path": ".", "target_path": "/config"}],
|
||||
"source",
|
||||
)
|
||||
assert len(result) == 2
|
||||
@@ -296,7 +296,7 @@ class TestResolveProfile:
|
||||
env_vars={},
|
||||
files={},
|
||||
git_mounts=[
|
||||
{"repo_id": "repo1", "source_path": ".", "target_path": "/app"},
|
||||
{"remote_url": "https://github.com/user/repo1.git", "source_path": ".", "target_path": "/app"},
|
||||
],
|
||||
)
|
||||
db_session.add(profile)
|
||||
@@ -304,7 +304,7 @@ class TestResolveProfile:
|
||||
|
||||
result = await resolve_profile(db_session, profile.id)
|
||||
assert len(result.git_mounts) == 1
|
||||
assert result.git_mounts[0]["repo_id"] == "repo1"
|
||||
assert result.git_mounts[0]["remote_url"] == "https://github.com/user/repo1.git"
|
||||
assert result.git_mounts[0]["target_path"] == "/app"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -320,7 +320,7 @@ class TestResolveProfile:
|
||||
env_vars={},
|
||||
files={},
|
||||
git_mounts=[
|
||||
{"repo_id": "repo1", "source_path": ".", "target_path": "/app"},
|
||||
{"remote_url": "https://github.com/user/repo1.git", "source_path": ".", "target_path": "/app"},
|
||||
],
|
||||
)
|
||||
db_session.add(base)
|
||||
@@ -333,7 +333,7 @@ class TestResolveProfile:
|
||||
env_vars={},
|
||||
files={},
|
||||
git_mounts=[
|
||||
{"repo_id": "repo2", "source_path": "config", "target_path": "/config"},
|
||||
{"remote_url": "https://github.com/user/repo2.git", "source_path": "config", "target_path": "/config"},
|
||||
],
|
||||
)
|
||||
db_session.add(child)
|
||||
|
||||
Reference in New Issue
Block a user