2

GitHub - kubero-dev/GitGenie: 💡GitGenie is a git plugin that creates commit mess...

 1 year ago
source link: https://github.com/kubero-dev/GitGenie
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

mascot.png

GitGenie

Once upon a time, there was a magical genie who lived inside Git as a plugin. This genie loved to help developers write better commit messages when they changed their code.

The genie was very clever and used its magic ChatGPT powers to analyze the changes in the code and suggest good messages for the developers to use.

And if the developers weren't happy with any of the suggestions, he would open an editor and give them the opportunity to adjust the suggestions to their liking.

Note The genie needs your help: There are binaries for Linux and Windows (ARM and x86_64). I have only a Mac(x86_64) to test the binaries. If you have a Windows/Linux or ARM architecture please let me know in the issues section if it works.

Usage

git add . 
git gci 
git gci [flags]

Flags:
  -d, --debug                Print debug information
  -f, --fast                 Skip editing the commit message
  -h, --help                 help for git
  -H, --host string          OpenAI API host (default "api.openai.com")
  -L, --language string      Commit message language: en, ch, de, es, fr, it, ja, ko, pt, zh (default "en")
  -l, --length string        Commit message length: short, medium, long, verylong (default "medium")
  -s, --signoff              Add signing signature to commit message
  -n, --suggestions string   Number of suggestions to generate (default "3")
  -v, --version              version for git

demo.gif

Installation

Download the binary for you operating system from the releases page and extract it to /usr/local/bin or any other directory in your PATH.

tar -xvzf GitGenie_Mac_x86_64.tar.gz -C /usr/local/bin

export OPENAI_API_KEY=sk-y..............................

Add the OpenAI Key ENV to your .bashrc or .zshrc and configure your Genie with the following additional ENV variables to change the default behavior.

  • OPENAI_API_KEY: OpenAI API token (required)
  • OPENAI_HOST: OpenAI API host (default: api.openai.com)
  • EDITOR or VISUAL: Editor to edit commit message (default: vim)
  • GENIE_SUGESTIONS: Number of suggestions to generate (default: 3)
  • GENIE_LENGTH: Length of each suggestion (default: medium, can be short, medium, long, verylong)
  • GENIE_MAX_TOKENS: Maximum number of tokens to generate (overrides GENIE_LENGTH)
  • GENIE_SKIP_EDIT: Skip editing the commit message (default: false)
  • GENIE_LANGUAGE: Language to use for the commit message (default: en, can be en, ch, de, es, fr, it, ja, ko, pt, ru, zh)
  • GENIE_DIFFCONTEXT: Number of lines of context to use for the diff (default: 5)

Privacy

There may be many reasons a repository owner does not want to allow genie generated commit messages or code to be sent to a third party service. For this reason, the repository can be configured to block GitGenie completly.

To block the genie, create a file called .gitgenieblock in the root of your repository and add the following content:

echo "https://github.com/kubero-dev/GitGenie" > .gitgenieblock

Repository Configuration (optional)

Prepare your repository for GitGenie by adding a .gitgenie file to the root of your repository. This file can be used to configure the genie for your repository.

Parameters:

  • language: Language to use for the commit message (default: en, can be en, ch, de, es, fr, it, ja, ko, pt, ru, zh)
  • description: Description of the repository/software (default: "")

Examples

Create a commit message with 5 suggestions and skip editing the commit message

git gci -n 5 -f

Create a commit message in a different language and use a short commit message

git gci -L de -l short

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK