feat: map commit_files in task capability resolver (#262)
Add commit_files and gitea_commit_files resolver entries for gitea.repo.commit, align gitea_commit_files tool gates with other issue-write mutations, and add regression tests for author allow, reviewer deny, preflight order, and resolver/tool alignment. Refs #262 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -1069,11 +1069,22 @@ class TestGetFile(unittest.TestCase):
|
||||
# ---------------------------------------------------------------------------
|
||||
# Commit Files
|
||||
# ---------------------------------------------------------------------------
|
||||
COMMIT_FILES_ENV = {
|
||||
"GITEA_PROFILE_NAME": "commit-author",
|
||||
"GITEA_ALLOWED_OPERATIONS": "gitea.read,gitea.repo.commit",
|
||||
"GITEA_FORBIDDEN_OPERATIONS": "gitea.pr.approve,gitea.pr.merge",
|
||||
}
|
||||
|
||||
|
||||
class TestCommitFiles(unittest.TestCase):
|
||||
|
||||
@patch("mcp_server.role_session_router.check_author_mutation_after_reviewer_stop",
|
||||
return_value=(True, []))
|
||||
@patch("mcp_server.api_request")
|
||||
@patch("mcp_server.get_auth_header", return_value=FAKE_AUTH)
|
||||
def test_commit_files_success(self, _auth, mock_api):
|
||||
def test_commit_files_success(self, _auth, mock_api, _role):
|
||||
mcp_server.record_preflight_check("whoami")
|
||||
mcp_server.record_preflight_check("capability", resolved_role="author")
|
||||
mock_api.return_value = {
|
||||
"commit": {"sha": "commit-sha-123"},
|
||||
"branch": {"name": "test-branch"}
|
||||
@@ -1081,11 +1092,12 @@ class TestCommitFiles(unittest.TestCase):
|
||||
files = [
|
||||
{"operation": "create", "path": "test.txt", "content": "SGVsbG8="}
|
||||
]
|
||||
result = gitea_commit_files(
|
||||
files=files,
|
||||
message="Initial commit",
|
||||
new_branch="test-branch"
|
||||
)
|
||||
with patch.dict(os.environ, COMMIT_FILES_ENV, clear=False):
|
||||
result = gitea_commit_files(
|
||||
files=files,
|
||||
message="Initial commit",
|
||||
new_branch="test-branch"
|
||||
)
|
||||
self.assertTrue(result["success"])
|
||||
self.assertEqual(result["commit"], "commit-sha-123")
|
||||
self.assertEqual(result["branch"], "test-branch")
|
||||
|
||||
Reference in New Issue
Block a user