feat(packages): add commit script to automate commit message generation
This commit is contained in:
parent
e5f942acbe
commit
e0887268bd
2 changed files with 25 additions and 0 deletions
|
@ -63,6 +63,7 @@ in
|
||||||
pantheon.rebuild
|
pantheon.rebuild
|
||||||
pantheon.deploy
|
pantheon.deploy
|
||||||
pantheon.edit
|
pantheon.edit
|
||||||
|
pantheon.commit
|
||||||
inputs.nixspect.packages."x86_64-linux".nixspect
|
inputs.nixspect.packages."x86_64-linux".nixspect
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
24
packages/commit/default.nix
Normal file
24
packages/commit/default.nix
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
pkgs.writeShellScriptBin "commit" # bash
|
||||||
|
''
|
||||||
|
PROMPT="Please generate a one-line commit message using."
|
||||||
|
GUIDELINES="1. Use conventional commit syntax, following the context."
|
||||||
|
NUM_ANCESTORS=0
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--num-ancestors | -n)
|
||||||
|
NUM_ANCESTORS="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unrecognised argument: $1. Exiting..."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
CONTEXT=$(git --no-pager log -n 10)
|
||||||
|
DIFF=$(git --no-pager diff HEAD~$NUM_ANCESTORS)
|
||||||
|
RESPONSE=$(aichat "$PROMPT\nGuidelines: $GUIDELINES\nContext from git log: $CONTEXT\nDiff from git diff HEAD: $DIFF")
|
||||||
|
#TODO: revise commit message
|
||||||
|
git commit -am "$RESPONSE"
|
||||||
|
''
|
Loading…
Add table
Add a link
Reference in a new issue