MCPcopy
hub / github.com/di-sukharev/opencommit / generateCommitMessageFromGitDiff

Function generateCommitMessageFromGitDiff

out/cli.cjs:85777–85926  ·  view source on GitHub ↗
({
  diff,
  extraArgs: extraArgs2,
  context = "",
  fullGitMojiSpec = false,
  skipCommitConfirmation = false
})

Source from the content-addressed store, hash-verified

85775};
85776var checkMessageTemplate = (extraArgs2) => {
85777 for (const key in extraArgs2) {
85778 if (extraArgs2[key].includes(config6.OCO_MESSAGE_TEMPLATE_PLACEHOLDER))
85779 return extraArgs2[key];
85780 }
85781 return false;
85782};
85783var generateCommitMessageFromGitDiff = async ({
85784 diff,
85785 extraArgs: extraArgs2,
85786 context = "",
85787 fullGitMojiSpec = false,
85788 skipCommitConfirmation = false
85789}) => {
85790 await assertGitRepo();
85791 const commitGenerationSpinner = le();
85792 commitGenerationSpinner.start("Generating the commit message");
85793 try {
85794 let commitMessage = await generateCommitMessageByDiff(
85795 diff,
85796 fullGitMojiSpec,
85797 context
85798 );
85799 const messageTemplate = checkMessageTemplate(extraArgs2);
85800 if (config6.OCO_MESSAGE_TEMPLATE_PLACEHOLDER && typeof messageTemplate === "string") {
85801 const messageTemplateIndex = extraArgs2.indexOf(messageTemplate);
85802 extraArgs2.splice(messageTemplateIndex, 1);
85803 commitMessage = messageTemplate.replace(
85804 config6.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
85805 commitMessage
85806 );
85807 }
85808 commitGenerationSpinner.stop("\u{1F4DD} Commit message generated");
85809 ce(
85810 `Generated commit message:
85811${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014")}
85812${commitMessage}
85813${source_default.grey("\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014")}`
85814 );
85815 const userAction = skipCommitConfirmation ? "Yes" : await ee({
85816 message: "Confirm the commit message?",
85817 options: [
85818 { value: "Yes", label: "Yes" },
85819 { value: "No", label: "No" },
85820 { value: "Edit", label: "Edit" }
85821 ]
85822 });
85823 if (hD2(userAction)) process.exit(1);
85824 if (userAction === "Edit") {
85825 const textResponse = await J4({
85826 message: "Please edit the commit message: (press Enter to continue)",
85827 initialValue: commitMessage
85828 });
85829 commitMessage = textResponse.toString();
85830 }
85831 if (userAction === "Yes" || userAction === "Edit") {
85832 const committingChangesSpinner = le();
85833 committingChangesSpinner.start("Committing the changes");
85834 const { stdout } = await execa("git", [

Callers 1

commitFunction · 0.70

Calls 15

hD2Function · 0.85
execaFunction · 0.85
assertGitRepoFunction · 0.70
checkMessageTemplateFunction · 0.70
getGitRemotesFunction · 0.70
hasUpstreamBranchFunction · 0.70
getCurrentBranchFunction · 0.70
displayPushUrlFunction · 0.70
getConfigFunction · 0.70
formatUserFriendlyErrorFunction · 0.70
printFormattedErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…