From 75f8055f43af192513f9b491435baeecb6705ee8 Mon Sep 17 00:00:00 2001 From: Daniel Palma Date: Sat, 25 Nov 2023 14:31:29 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=9E:=20Update=20installation=20and=20u?= =?UTF-8?q?sage=20instructions=20for=20pre-commit=20and=20git-genie=20hook?= =?UTF-8?q?s.=20Add=20guidelines=20for=20generating=20and=20explaining=20c?= =?UTF-8?q?omplex=20git=20commands.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 +++++++++++++++++--- git_genie/main.py | 4 +++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index acb4efb..bcdcaff 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,11 @@ Generated command: git commit -m 'Update README with commit message example and ### Generate commit messages as a pre-commit hook -#### Install pre-commit +#### Install pre-commit & git-genie hooks ```shell pip install pre-commit +pre-commit install --hook-type commit-msg ``` #### Add pre-commit hook @@ -32,15 +33,28 @@ repos: #### Watch the magic happen ```shell -~/Personal/git-genie-pre-commit main* ❯ git add . && git commit -m "test" +~/Personal/git-genie-pre-commit main* ❯ git add . && git commit -m "git-genie please help me write a commit message" git-genie................................................................Passed -[main 0dc8c69] test 🧞: Specify specific revision and add '--mode=replace' argument to git-genie hook. +[main 0dc8c69] git-genie please help me write a commit message 🧞: Update .pre-commit-config.yaml for git-genie v0.1.1 Add --fix and --exit-non-zero-on-fix for ruff hooks. 1 file changed, 2 insertions(+), 1 deletion(-) ``` +In the above example, the commit message includes the original message and the message generated by git-genie. +If you with to replace the original message, use `--mode=replace` instead of `--mode=append`. + +The results will be similar to the following: + +```shell +~/Personal/git-genie-pre-commit main* ⇡ ❯ git commit -m "asdsakdfnlsknflag" 3.10.7 repobuddy 14:26:04 + +git-genie................................................................Passed +[main 9bf1d83] 🧞: Update pre-commit hook to use "--mode=replace" and change port mapping to "5435:5435". + 2 files changed, 2 insertions(+), 2 deletions(-) +``` + ### Generate & Explain complex git commands using plain english ![example](example.png) diff --git a/git_genie/main.py b/git_genie/main.py index bd458a4..3cfc38d 100644 --- a/git_genie/main.py +++ b/git_genie/main.py @@ -189,7 +189,9 @@ def generate_commit_message(diff: str) -> str: giving a command. The first line should be no longer than 50 characters and should start with a capital letter. The following lines should be no longer than 72 characters. - Only focus on the changed lines. Do not include lines that were not changed. + In the Changes below, the lines that start with a + are lines that were added. The lines that start with a - are + lines that were removed. Other lines are unchanged. Only focus on the changed lines. Do not include lines that + were not changed. Be direct, try to eliminate filler words and phrases in these sentences (examples: though, maybe, I think, kind of). Think like a journalist. Be concise. Be clear. Be consistent. Be professional. Be respectful.