No project description provided
Project description
git-genie 🧞
Generate & explain git commands using plain english.
Generate commit messages based on staged changes
❯ git-genie commit
Generated command: git commit -m 'Update README with commit message example and instructions'
Generate & Explain complex git commands using plain english
Installation
pip install git-genie
Usage
❯ git-genie [OPTIONS] INSTRUCTION
For example:
❯ git-genie --explain "Who was the last person to modify the README.md file?"
Options:
--explain
,-e
: Explain the generated git command automatically.--execute
,-x
: Execute the generated git command automatically.--install-completion
: Install completion for the current shell.--show-completion
: Show completion for the current shell, to copy it or customize the installation.--help
,-h
: Show this message and exit.
If no options are provided, the program will run in interactive mode.
Optionally, you can add a "gg" alias to your shell's rc file (e.g. ~/.bashrc) to make the command shorter:
alias gg="git-genie"
Pre-requisites
OpenAI API key
export OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Generate commit messages
Generating commit messages is done by using the commit
command.
This method will create a concise message based on the changes staged for a commit.
❯ git status
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: README.md
Let's generate a commit message for the changed README.md file:
❯ git-genie commit
Generated commit command:git commit -m 'Update README with commit message example and instructions'
(E)xplain or e(X)ecute or (N)ew?: X
By pressing X
, the generated commit command will be executed automatically:
Running command: git commit -m 'Update README with commit message example and instructions'
Output:
[commit_gen 75d69ce] Update README with commit message example and instructions
1 file changed, 19 insertions(+)
Interactive mode
By default, the program will run in interactive mode, where it will ask you if you would like to explain the generated git command, execute it, or generate a new command.
~/git-genie ❯ git-genie "count how many times the README.md file was modified in the last week"
Generated git command: git log --since=1.week -- README.md | grep "^commit" | wc -l
(E)xplain or e(X)ecute or (N)ew?: E
Explanation
git log -> Show commit logs
--since=1.week -> Show commits more recent than a specific date
-- README.md -> Only commits that affect README.md
| -> Pipe the output of the previous command to the next command
grep "^commit" -> Only show lines that start with "commit"
wc -l -> Count the number of lines
e(X)ecute or (N)ew?: X
Running command: git log --since=1.week -- README.md | grep "^commit" | wc -l
Output:
2
Non-interactive mode
Explain
By using the --explain
flag, the program will print the explanation of the generated git command.
~/git-genie ❯ git-genie "amend all previous commits with new email address" --explain
Generated git command: git rebase -i HEAD~5 --autosquash -m "legacy code"
Explanation
git rebase -> Forward-port local commits to the updated upstream head
-i, --interactive -> Make a list of the commits which are about to be rebased.Let the user edit that list before rebasing.
--autosquash -> Automatically move commits that begin with squash!/fixup! to the beginningof the todo list.
-m, --merge -> Use the given message as the merge commit message.If multiple -m options are given, their values are concatenated as separate paragraphs.
HEAD~5 -> The last 5 commits
legacy code -> The message of the merge commit
Execute
By using the --execute
flag, the program will execute the generated git command automatically without asking for
confirmation.
~/git-genie ❯ git-genie "print last 5 commits logs, condensed" --execute
Generated git command: git log -5 --oneline
Running command: git log -5 --oneline
Output:
9a33bc3 update email
f76f041 CLI interface
ae8abbd Add pycache to gitignore
67169fd rich print
3bac238 Refactor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file git_genie-0.2.0.tar.gz
.
File metadata
- Download URL: git_genie-0.2.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
5437f6395abbbb4e20371531d6305e1a080fa278f2de4797403bcded7512de04
|
|
MD5 |
a05a0c2c47337992507c5d6007ea983e
|
|
BLAKE2b-256 |
8fefb35f33a28a5b8e42021c3fb05f7cd92144037e12de6baffd2824c5db8769
|
File details
Details for the file git_genie-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: git_genie-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.9 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
73efe0206675016686c845729c99e3283bd7930134dbd55076c539166c3ba7c2
|
|
MD5 |
8ee6841e3db30d876b56e3a6ad2ed895
|
|
BLAKE2b-256 |
bcfe6f9a5c525b537bac43fa99ccb780aa7c6776c3eaa6947e55848d9bde9003
|