Skip to content

Feat/run with git commit gpt#8

Merged
jackbackes merged 4 commits into
masterfrom
feat/run-with-git-commit-gpt
Apr 18, 2023
Merged

Feat/run with git commit gpt#8
jackbackes merged 4 commits into
masterfrom
feat/run-with-git-commit-gpt

Conversation

@jackbackes
Copy link
Copy Markdown
Owner

No description provided.

Body:
This commit adds a Bash script that installs git-commit-gpt, a tool that integrates OpenAI's GPT-3 language model into Git commit messages to help write more descriptive and professional messages.

The script checks if happycommit is in the user's PATH before proceeding with the installation. It also adds the git-commit-gpt command to the user's shell configuration file to ensure it's available every time the shell starts up.

If the OPENAI_API_KEY is not in the happycommit config file, the script prompts the user to enter it and adds it to the file. If it's already in the file, the script gives the user the option to update it.

The script is officially supported on Bash and Zsh, and works on macOS as well as other Unix-based systems.

Testing:
The installation script was successfully tested on a macOS machine running zsh. It has not been tested on a Linux machine. and on an Ubuntu machine running Zsh. The script successfully detected an invalid happycommit installation and prompted the user to install it. The script also successfully added git-commit-gpt to the .zshrc file on the Mac. Additionally, the script prompted the user to enter the OPENAI_API_KEY and added it to the config.toml file.
This commit adds several dependencies in the project, including `dirs` and `toml`, and installs with their latest versions.

Full list of updates:
- `dirs` has been added at version 5.0.0
- `toml` has been added at version 0.7.3

All existing tests have passed successfully after updating dependencies.

Note: No code changes were made in this commit.
The 'install' command has been added to the Justfile. This command builds and installs the binary using 'cargo install' command. It is now easier for users to quickly install the binary and start using it without having to manually build it from source.

No testing was done for this commit.

Note that the other tasks in the Justfile, 'format' and 'clippy', can now be run using the 'fix' command, as described in the file.
This commit enhances the loading of the OpenAI API key in the codebase. Previously, it could only be loaded from a .env file. Now it can also be loaded from the .happycommit/config.toml file, which is used by the install script. However, if it is not found in either location, the code will throw an error.

With this commit, we have created a function `load_api_key()` that first checks the `.happycommit/config.toml` file, and then checks the `.env` file for the API key. This ensures that the OpenAI API key can be easily loaded and used in the code.

In addition to this, we have fixed a clippy warning regarding the use of unnecessary borrowing in the `stream_multipart_commit_message` function.

Testing:
- Tested that the OpenAI API key could be loaded from both the `.env` file and the `config.toml` file.
- Verified that the app quits when the API key is not found in either file.
- Ran all tests and ensured that they passed.

Changes:
- Created `load_api_key()` function to handle loading of OpenAI API key.
- Fixed clippy warning regarding unnecessary borrowing in `stream_multipart_commit_message` function.
@jackbackes jackbackes merged commit eae3b1f into master Apr 18, 2023
@jackbackes jackbackes deleted the feat/run-with-git-commit-gpt branch April 18, 2023 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant