MCPcopy
hub / github.com/openai/codex-plugin-cc / collectBranchContext

Function collectBranchContext

plugins/codex/scripts/lib/git.mjs:261–289  ·  view source on GitHub ↗
(cwd, baseRef, options = {})

Source from the content-addressed store, hash-verified

259}
260
261function collectBranchContext(cwd, baseRef, options = {}) {
262 const includeDiff = options.includeDiff !== false;
263 const comparison = options.comparison ?? buildBranchComparison(cwd, baseRef);
264 const currentBranch = getCurrentBranch(cwd);
265 const changedFiles = gitChecked(cwd, ["diff", "--name-only", comparison.commitRange]).stdout.trim().split("\n").filter(Boolean);
266 const logOutput = gitChecked(cwd, ["log", "--oneline", "--decorate", comparison.commitRange]).stdout.trim();
267 const diffStat = gitChecked(cwd, ["diff", "--stat", comparison.commitRange]).stdout.trim();
268
269 return {
270 mode: "branch",
271 summary: `Reviewing branch ${currentBranch} against ${baseRef} from merge-base ${comparison.mergeBase}.`,
272 content: includeDiff
273 ? [
274 formatSection("Commit Log", logOutput),
275 formatSection("Diff Stat", diffStat),
276 formatSection(
277 "Branch Diff",
278 gitChecked(cwd, ["diff", "--binary", "--no-ext-diff", "--submodule=diff", comparison.commitRange]).stdout
279 )
280 ].join("\n")
281 : [
282 formatSection("Commit Log", logOutput),
283 formatSection("Diff Stat", diffStat),
284 formatSection("Changed Files", changedFiles.join("\n"))
285 ].join("\n"),
286 changedFiles,
287 comparison
288 };
289}
290
291function buildAdversarialCollectionGuidance(options = {}) {
292 if (options.includeDiff !== false) {

Callers 1

collectReviewContextFunction · 0.85

Calls 4

buildBranchComparisonFunction · 0.85
getCurrentBranchFunction · 0.85
gitCheckedFunction · 0.85
formatSectionFunction · 0.85

Tested by

no test coverage detected