MCPcopy Create free account
hub / github.com/echoVic/blade-code / postProcessResult

Method postProcessResult

src/tools/builtin/git/git-add.ts:237–283  ·  view source on GitHub ↗

* 后处理结果

(
    result: { stdout: string; stderr: string },
    params: Record<string, any>
  )

Source from the content-addressed store, hash-verified

235 * 后处理结果
236 */
237 protected async postProcessResult(
238 result: { stdout: string; stderr: string },
239 params: Record<string, any>
240 ): Promise<any> {
241 const output = result.stdout.trim();
242
243 if (params.dryRun) {
244 // 解析干运行结果
245 const lines = output.split('\n').filter(line => line.trim());
246 const wouldAdd = lines.map(line => line.replace(/^add\s+/, ''));
247
248 return {
249 type: 'dry-run',
250 wouldAdd,
251 fileCount: wouldAdd.length,
252 message: `将要添加 ${wouldAdd.length} 个文件到暂存区`,
253 rawOutput: output,
254 };
255 }
256
257 // 实际添加操作 - 获取当前暂存区状态
258 try {
259 const { stdout: statusOutput } = await execAsync('git status --porcelain', {
260 cwd: params.path || '.',
261 timeout: 5000,
262 });
263
264 const statusLines = statusOutput.split('\n').filter(line => line.trim());
265 const stagedFiles = statusLines
266 .filter(line => line[0] !== ' ' && line[0] !== '?')
267 .map(line => line.substring(3));
268
269 return {
270 type: 'add',
271 stagedFiles,
272 stagedCount: stagedFiles.length,
273 message: output || `成功添加文件到暂存区`,
274 rawOutput: output,
275 };
276 } catch (statusError) {
277 return {
278 type: 'add',
279 message: output || '文件已添加到暂存区',
280 rawOutput: output,
281 };
282 }
283 }
284}
285
286// 导出工具实例

Callers 1

executeCommandFunction · 0.45

Calls 1

filterMethod · 0.45

Tested by

no test coverage detected