gitea_compliance_check_all
Run comprehensive compliance checks on branches, commits, and pull requests to identify policy violations and generate detailed reports for Gitea repositories.
Instructions
Run comprehensive compliance check on branch, commits, and/or PR. Returns detailed report.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | No | Repository owner. Uses context if not provided | |
| repo | No | Repository name. Uses context if not provided | |
| branch | No | Branch name to check | |
| pr_number | No | PR number to check (also checks its commits) | |
| commit_count | No | Max number of commits to check (default: 10) | |
| config_path | No | Path to compliance config file | |
| token | No | Optional API token to override default authentication |
Implementation Reference
- src/tools/compliance.ts:469-555 (handler)The primary handler function `checkAll` that performs comprehensive compliance checks for branches, commits, and pull requests in Gitea repositories.export async function checkAll( ctx: ComplianceToolsContext, params: CheckAllParams ): Promise<AllCheckResult> { const owner = ctx.contextManager.resolveOwner(params.owner); const repo = ctx.contextManager.resolveRepo(params.repo); logger.info({ owner, repo }, 'Running comprehensive compliance check'); const result: AllCheckResult = { summary: { total_checks: 0, passed: 0, failed: 0, compliant: true, }, }; // 1. 检查分支(如果提供) if (params.branch) { result.branch = await checkBranch(ctx, { branch: params.branch, config_path: params.config_path, }); result.summary.total_checks++; if (result.branch.compliant) { result.summary.passed++; } else { result.summary.failed++; result.summary.compliant = false; } } // 2. 检查 PR(如果提供) if (params.pr_number) { result.pr = await checkPR(ctx, { owner, repo, pr_number: params.pr_number, config_path: params.config_path, token: params.token, }); result.summary.total_checks++; if (result.pr.compliant) { result.summary.passed++; } else { result.summary.failed++; result.summary.compliant = false; } // 如果有 PR,检查其关联的提交 try { const commitsResponse = await ctx.client.request({ method: 'GET', path: `/repos/${owner}/${repo}/pulls/${params.pr_number}/commits`, token: params.token, }); const commits = (commitsResponse.data as any[]) || []; const commitCount = params.commit_count || 10; const commitsToCheck = commits.slice(0, commitCount); result.commits = []; for (const commit of commitsToCheck) { const commitResult = await checkCommit(ctx, { owner, repo, sha: commit.sha, message: commit.commit?.message, config_path: params.config_path, token: params.token, }); result.commits.push(commitResult); result.summary.total_checks++; if (commitResult.compliant) { result.summary.passed++; } else { result.summary.failed++; result.summary.compliant = false; } } } catch (err) { logger.warn({ pr: params.pr_number, error: err }, 'Failed to fetch PR commits'); } } return result; }
- src/tools-registry/compliance-registry.ts:90-114 (registration)Registers the 'gitea_compliance_check_all' tool with MCP server, including input schema and wrapper handler that delegates to ComplianceTools.checkAll.mcpServer.registerTool( 'gitea_compliance_check_all', { title: '综合规范检查', description: 'Run comprehensive compliance check on branch, commits, and/or PR. Returns detailed report.', inputSchema: z.object({ owner: z.string().optional().describe('Repository owner. Uses context if not provided'), repo: z.string().optional().describe('Repository name. Uses context if not provided'), branch: z.string().optional().describe('Branch name to check'), pr_number: z.number().int().positive().optional().describe('PR number to check (also checks its commits)'), commit_count: z.number().int().positive().optional().describe('Max number of commits to check (default: 10)'), config_path: z.string().optional().describe('Path to compliance config file'), token: tokenSchema, }), }, async (args) => { try { const result = await ComplianceTools.checkAll(toolsContext, args as any); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text' as const, text: `Error: ${errorMessage}` }], isError: true }; } } );
- Zod input schema defining parameters for the gitea_compliance_check_all tool: owner, repo, branch, pr_number, commit_count, config_path, token.inputSchema: z.object({ owner: z.string().optional().describe('Repository owner. Uses context if not provided'), repo: z.string().optional().describe('Repository name. Uses context if not provided'), branch: z.string().optional().describe('Branch name to check'), pr_number: z.number().int().positive().optional().describe('PR number to check (also checks its commits)'), commit_count: z.number().int().positive().optional().describe('Max number of commits to check (default: 10)'), config_path: z.string().optional().describe('Path to compliance config file'), token: tokenSchema,
- src/tools/compliance.ts:459-464 (schema)TypeScript interface CheckAllParams defining the input parameters for the checkAll handler function.export interface CheckAllParams extends ComplianceParams { branch?: string; pr_number?: number; commit_count?: number; config_path?: string; }
- src/tools/compliance.ts:151-161 (schema)TypeScript interface AllCheckResult defining the structured output of the checkAll function.export interface AllCheckResult { branch?: BranchCheckResult; commits?: CommitCheckResult[]; pr?: PRCheckResult; summary: { total_checks: number; passed: number; failed: number; compliant: boolean; }; }