MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / splitDiff

Function splitDiff

out/cli.cjs:85583–85607  ·  view source on GitHub ↗
(diff, maxChangeLength)

Source from the content-addressed store, hash-verified

85581 fullGitMojiSpec,
85582 context
85583 );
85584 return engine.generateCommitMessage(messages);
85585 }
85586 );
85587 return commitMsgsFromFileLineDiffs;
85588}
85589function splitDiff(diff, maxChangeLength) {
85590 const lines = diff.split("\n");
85591 const splitDiffs = [];
85592 let currentDiff = "";
85593 if (maxChangeLength <= 0) {
85594 throw new Error(GenerateCommitMessageErrorEnum.outputTokensTooHigh);
85595 }
85596 for (let line of lines) {
85597 while (tokenCount(line) > maxChangeLength) {
85598 const subLine = line.substring(0, maxChangeLength);
85599 line = line.substring(maxChangeLength);
85600 splitDiffs.push(subLine);
85601 }
85602 if (tokenCount(currentDiff) + tokenCount("\n" + line) > maxChangeLength) {
85603 splitDiffs.push(currentDiff);
85604 currentDiff = line;
85605 } else {
85606 currentDiff += "\n" + line;
85607 }
85608 }
85609 if (currentDiff) {
85610 splitDiffs.push(currentDiff);

Callers 1

Calls 2

tokenCountFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…