Skip to content

Commit 782ce1b

Browse files
authored
Merge pull request #285 from tbrandenburg/codex/exclude-crontab-yml-in-worktrees
2 parents e432718 + 752e82e commit 782ce1b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

packages/pybackend/tests/unit/test_workflow_service.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,41 @@ def test_list_workspace_workflows_collects_repository_workflows(
104104
}
105105
]
106106
}
107+
108+
109+
@patch("workflow_service.read_workflows")
110+
@patch("workflow_service.get_workspace_home")
111+
def test_list_workspace_workflows_skips_git_worktrees(
112+
mock_workspace_home, mock_read_workflows
113+
):
114+
mock_workspace_home.return_value = Path("/workspace/home")
115+
116+
repo = Path("/workspace/home/repo-a")
117+
worktree = Path("/workspace/home/repo-a-feature")
118+
119+
with patch.object(Path, "iterdir", return_value=[repo, worktree]), patch.object(
120+
Path, "is_dir", return_value=True
121+
), patch.object(Path, "is_file", side_effect=[False, True]):
122+
mock_read_workflows.return_value = {
123+
"workflows": [
124+
{"id": "wf_a", "name": "A", "enabled": True, "schedule": "* * * * *"}
125+
]
126+
}
127+
128+
result = list_workspace_workflows()
129+
130+
assert result == {
131+
"workflows": [
132+
{
133+
"repository": "repo-a",
134+
"id": "wf_a",
135+
"name": "A",
136+
"enabled": True,
137+
"schedule": "* * * * *",
138+
"shellScriptPath": None,
139+
"lastRun": None,
140+
"diagnostics": None,
141+
}
142+
]
143+
}
144+
mock_read_workflows.assert_called_once_with("repo-a")

packages/pybackend/workflow_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def list_workspace_workflows(
124124
for repo_path in workspace_home.iterdir():
125125
if not repo_path.is_dir():
126126
continue
127+
if (repo_path / ".git").is_file():
128+
continue
127129

128130
repo_name = repo_path.name
129131
repository_workflows = read_workflows(repo_name).get("workflows", [])

0 commit comments

Comments
 (0)