mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-01-29 15:38:01 -05:00
8b0ee25923eaeadd76a641b739dadfe802d87a40
53 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0d1f72bdec |
Feature: add staged files multiple selection (#6)
* chore(package.json): add "@bdsqqq/try" dependency * refactor(api.ts): remove unnecessary whitespace * refactor(cli.ts): remove unused imports and variables * refactor(commit.ts): rename getStagedGitDiff to getDif * refactor(commit.ts): add getStagedFiles and getChangedFiles functions * feat(commit.ts): add multiselect prompt to select files to stage * feat(commit.ts): add gitAdd function to stage selected files * feat(commit.ts): add trytm function to handle errors * feat(commit.ts): add exitProgram function to exit the program with an error message if an error occurs during execution * refactor(commit.ts): refactor commit function to handle unstaged files * feat(commit.ts): add multiselect prompt to select files to add to commit when there are unstaged files * feat(git.ts): add getStagedFiles function to get list of staged files * feat(git.ts): add getChangedFiles function to get list of changed files * feat(git.ts): add gitAdd function to add files to commit * feat(git.ts): add getDif function to get diff of staged files * refactor(commit.ts): replace exitProgram function with process.exit(1) to exit the program * refactor(commit.ts): change message prompt to English in multiselect function * chore(package.json): add prettier to format code * refactor(api.ts): remove unnecessary whitespace and comments * refactor(commit.ts): add missing semicolons and fix formatting * feat(commit.ts): add support for selecting files to add to the commit when there are changed files but no staged files * refactor(commit.ts): add isStageAllFlag parameter to commit function * refactor(commit.ts): add whitespace to getDif function call * refactor(commit.ts): add whitespace to generateCommitMessageFromGitDiff function call * refactor(git.ts): reformat code for better readability * chore(git.ts): add semicolons to the end of each statement * chore(package.json): remove "@bdsqqq/try" dependency * refactor(commit.ts): move trytm function to utils/trytm.ts * refactor(commit.ts): add isStageAllFlag parameter to gitAdd function call in commit function * refactor(commit.ts): remove getStagedGitDiff function call and use getStagedFiles function call instead * refactor(commit.ts): add error handling to generateCommitMessageFromGitDiff function call in commit function * refactor(prepare-commit-msg-hook.ts): rename getStagedGitDiff to getStagedFiles * feat(prepare-commit-msg-hook.ts): add gitAdd function to stage changes before generating commit message * refactor(prepare-commit-msg-hook.ts): use getDif function to get staged changes diff instead of staged.diff * refactor(prepare-commit-msg-hook.ts): remove unnecessary if statement and return statement * refactor(git.ts): remove StagedDiff interface and getStagedGitDiff function * feat(git.ts): add support for untracked files in getChangedFiles function * refactor(git.ts): rename stdout variable in getChangedFiles function * refactor(git.ts): add excludeBigFilesFromDiff to getDif function * feat(trytm.ts): add trytm utility function for handling promises with try-catch block * fix(commit.ts): add missing function call parentheses in return statement * refactor(commit.ts): remove unused variable generateCommitResponse * refactor(commit.ts): exit process with code 0 after successful commit * fix(commit.ts): add check for no changes detected before opening commit prompt * fix(commit.ts): fix typo in function name from getDif to getDiff * fix(prepare-commit-msg-hook.ts): fix typo in function name from getDif to getDiff * refactor(git.ts): rename getDif function to getDiff for consistency and clarity * chore(git.ts): add excludeBigFilesFromDiff option to getStagedFiles function * chore(git.ts): import text function from @clack/prompts package * refactor(git.ts): remove excludeBigFilesFromDiff constant and filter out .lock files from getStagedFiles and getChangedFiles functions * feat(git.ts): add error message when all staged files are .lock files * feat(git.ts): add error message when all changed files are .lock files * feat(git.ts): add warning message when some files are .lock files and excluded from git add and git diff * refactor(git.ts): add filter to remove empty strings from returned array in getStagedFiles and getChangedFiles functions * refactor(commit.ts): pass isStageAllFlag to getChangedFiles function * fix(commit.ts): handle errorStagedFiles and errorChangedFiles variables * fix(git.ts): filter out empty strings from excludedFiles array * feat(git.ts): add isStageAllFlag parameter to getChangedFiles function to handle git add --all command * refactor(git.ts): remove console.log statement from getChangedFiles function and refactor code to improve readability * refactor(commit.ts): remove unnecessary parameter from getChangedFiles function call * refactor(git.ts): remove isStageAllFlag parameter from getChangedFiles function and add check for .lock files in the returned files list * refactor(commit.ts): remove unnecessary line breaks and whitespace * refactor(commit.ts): remove unnecessary parentheses in function calls * feat(git.ts): add someFilesExcludedMessage function to display excluded files message * refactor(git.ts): use someFilesExcludedMessage function instead of text function in getChangedFiles, gitAdd, and getDiff functions * refactor(git.ts): extract someFilesExcludedMessage function to handle excluded files message * fix(git.ts): use someFilesExcludedMessage function instead of throwing an error when all staged files are excluded files * refactor(git.ts): pad excluded files list with 5 spaces * refactor(git.ts): remove unnecessary padStart method call in someFilesExcludedMessage function * chore(git.ts): update someFilesExcludedMessage function to improve readability --------- Co-authored-by: Sukharev <57486732+di-sukharev@users.noreply.github.com> |
||
|
|
bf29c260ca |
* 🚀 feat(generateCommitMessageFromGitDiff.ts): add mergeStrings utility function
* 🐛 fix(generateCommitMessageFromGitDiff.ts): remove unnecessary separator variable * 🐛 fix: split file diffs by files * ✨ feat: add support for generating commit messages by file diffs * ✨ feat(generateCommitMessageFromGitDiff.ts): add mergeStrings utility function to merge string arrays * 🐛 fix(generateCommitMessageFromGitDiff.ts): reduce MAX_REQ_TOKENS to 1000 * ✨ feat(generateCommitMessageFromGitDiff.ts): add support for generating commit messages for large diffs by splitting them into smaller chunks and generating commit messages for each chunk using OpenAI's GPT-3 model. * ♻️ refactor: extract getCommitMsgsPromisesFromFileDiffs function from generateCommitMessage function * ♻️ refactor: extract getMessagesPromisesByLines function from getCommitMsgsPromisesFromFileDiffs function * ✨ feat: add support for merging file diffs into one commit message if it exceeds MAX_REQ_TOKENS limit * ✨ feat(mergeStrings.ts): add mergeStrings function to merge strings in an array based on maxStringLength |
||
|
|
eae7618d57 |
* 📝 docs(TODO.md): add TODOs
Added a TODO list with tasks that need to be completed. These tasks include building for both mjs and cjs, configuring esbuild to make the bundle smaller, adding // TODOs in the code, batching small files in one request, adding tests, and making the hook work. * ✨ feat(api.ts): add OpenAI class with generateCommitMessage method This commit adds a new OpenAI class with a generateCommitMessage method that uses the OpenAI API to generate a commit message based on an array of messages. The method takes an array of ChatCompletionRequestMessage objects and returns a Promise that resolves to a ChatCompletionResponseMessage object. The OpenAI class is exported as a singleton instance named api. * ✨ feat(prepare-commit-msg-hook.ts): add support for generating commit messages with chat completion This commit adds support for generating commit messages with chat completion. The `prepare-commit-msg-hook.ts` file now imports the `generateCommitMessageWithChatCompletion` function from the `generateCommitMessageFromGitDiff` module. The function generates a commit message based on the staged git diff and appends it to the commit message file. If the `OPENAI_API_KEY` environment variable is not set, an error is thrown. If the commit source is specified, the function returns without generating a commit message. * 🆕 feat(generateCommitMessageFromGitDiff.ts): add functionality to generate commit messages from git diff This commit adds a new file, generateCommitMessageFromGitDiff.ts, which contains a function that generates commit messages from the output of the 'git diff --staged' command. The function uses the OpenAI API to prompt the user to create a commit message in the conventional commit convention. The user can choose to use Gitmoji convention to preface the commit and add a short description of what the commit is about. * 🐛 fix(server.ts): change port variable case from lowercase port to uppercase PORT * ✨ feat(server.ts): add support for process.env.PORT environment variable The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable. * 🚀 feat: add function to generate commit messages from diff This commit adds a new function that generates commit messages from a diff. The function takes a diff as input and splits it into files. It then generates commit messages for each file and returns them as a concatenated string. If the total length of the commit message exceeds the maximum allowed length, the function skips the file. If the commit message is empty, the function skips the file. If an error occurs during the process, the function returns an error. * ✨ feat(git.ts): add function to assert git repository existence * ✨ feat(git.ts): add function to get staged git diff The assertGitRepo function checks if the current directory is a git repository by running the 'git rev-parse' command. If the command fails, an error is thrown. The getStagedGitDiff function returns the staged diff of the git repository. It takes an optional boolean argument isStageAllFlag, which when true stages all changes before getting the diff. The function uses the 'git diff --staged' command to get the diff and excludes big files from the diff. The function returns an object with two properties: files, which is an array of the names of the files that have changes, and diff, which is the diff of the staged changes. |