- Node.js
- An OpenAI API key
- Clone this repository
git clone [URL_OF_THIS_REPO]
- Go the repository directory
cd [REPO_DIRECTORY_NAME]
- Create a .env file in the root of the project by copying the existing .env.sample and add there your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key
- Install the plugin globally:
- Using npm:
npm install -g .
- Using yarn:
yarn global add file:$PWD
- Using npm:
Once installed globally, you can use the git-gen command in any Git repository to generate either commit messages or PR descriptions.
git-gen --cm
git-gen --prd --target-branch [YOUR_TARGET_BRANCH]
-
The --cm option fetches the git diff of your repository and sends it to OpenAI's API to generate a commit message. The message starts with a concise summary of the changes, followed by a more detailed description.
-
The --prd --target-branch [YOUR_TARGET_BRANCH] option fetches the commit history of your branch based on the commits that are unique to the current branch since it diverged from a target branch and sends it to OpenAI's API to generate a PR description in Markdown format.
- Ensure you have set up the .env file with your OpenAI API key before running the script.
- The script uses the --function-context option with git diff to provide more context about the changes. If the diff is too large, it falls back to a regular git diff.
If you'd like to contribute to this project, please create a pull request with your proposed changes.