feat(github): add auto-conventional-commit hook with opencode integration
- Add prepare-commit-msg git hook that generates conventional commit messages - Modularize fish configuration with separate conf.d files - Convert configuration files from .text to .source format for structured data - Add sops-nix SOPS configuration with explicit secret definitions - Upgrade age identity to single key file management approach - Add system activation script for age key management - Generate .sops.yaml for SOPS creation rules - Restructure README.md with improved table and cleaner formatting - Refactor config files to use pkgs.formats.json/toml generators - Implement YAML format for ashell and walker service configurations - Update SSH config source to use sops secrets - Convert zed and other config files to use structured .source format
This commit is contained in:
@@ -5,7 +5,40 @@
|
||||
}: let
|
||||
configFile = "git/config";
|
||||
ignoreFile = "git/ignore";
|
||||
hooksDir = "git/hooks";
|
||||
toINI = (pkgs.formats.ini {}).generate;
|
||||
|
||||
# Hook that auto-generates a Conventional Commit message from staged diff
|
||||
prepareCommitMsg = pkgs.writeShellScript "prepare-commit-msg" ''
|
||||
# Only run if there are staged changes
|
||||
if git diff --cached --quiet 2>/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Generating commit message from staged changes..." >&2
|
||||
|
||||
# Generate Conventional Commit message using opencode run
|
||||
git diff --cached | timeout 30 ${pkgs.opencode}/bin/opencode run \
|
||||
-m opencode/north-mini-code-free \
|
||||
"You are an expert software engineer writing professional Git commit messages.
|
||||
|
||||
Create a clean Conventional Commit for the provided diff.
|
||||
|
||||
Rules:
|
||||
- Format: type(optional scope): imperative description
|
||||
- Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
|
||||
- First line: maximum 72 characters, starts with capital letter, imperative present tense
|
||||
- If relevant, add a blank line followed by a short body explaining the motivation and key changes
|
||||
- Be concise and professional. No emojis, no markdown.
|
||||
|
||||
Output ONLY the commit message. Do not add any extra text, quotes, or explanations." \
|
||||
2>/dev/null > "$1"
|
||||
|
||||
# Fallback if generation failed or timed out
|
||||
if [ ! -s "$1" ]; then
|
||||
echo "chore: auto-generated commit message" > "$1"
|
||||
fi
|
||||
'';
|
||||
in {
|
||||
users.users.someone.packages = with pkgs; [
|
||||
git
|
||||
@@ -36,6 +69,7 @@ in {
|
||||
};
|
||||
core = {
|
||||
editor = "nvim";
|
||||
hooksPath = "${config.xdg.configHome}/git/hooks";
|
||||
pager = "${pkgs.delta}/bin/delta";
|
||||
whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
|
||||
excludesFile = "${config.xdg.configHome}/${ignoreFile}";
|
||||
@@ -124,4 +158,6 @@ in {
|
||||
AGENTS.md
|
||||
.sisyphus
|
||||
'';
|
||||
|
||||
xdg.configFile."${hooksDir}/prepare-commit-msg".source = prepareCommitMsg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user