({
diff,
extraArgs: extraArgs2,
context = "",
fullGitMojiSpec = false,
skipCommitConfirmation = false
})
| 85775 | }; |
| 85776 | var 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 | }; |
| 85783 | var 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", [ |
no test coverage detected
searching dependent graphs…