diff --git a/dev/flake.nix b/dev/flake.nix index a4df51ba..8797b0de 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -39,19 +39,18 @@ meta.description = program.meta.description; program = pkgs.writeShellApplication { name = "cz-check"; - runtimeInputs = [ pkgs.git config.pre-commit.settings.tools.commitizen ]; + runtimeInputs = with pkgs; [ config.pre-commit.settings.tools.commitizen git gnugrep coreutils ]; meta.description = "Verify commit messages from the default branch to HEAD follow conventional commit format"; text = '' - default_branch=$(git rev-parse --abbrev-ref origin/HEAD | sed 's@origin/@@') - current_branch=$(git rev-parse --abbrev-ref HEAD) + default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) - commit_count=$(git rev-list --count "$default_branch".."$current_branch") + commit_count=$(git rev-list --count "$default_branch"..HEAD) if [ "$commit_count" -eq 0 ]; then - echo "No commits to check between $default_branch and $current_branch." + echo "No commits to check between $default_branch and HEAD." else echo "Checking $commit_count commit(s)..." - cz check --rev-range "$default_branch".."$current_branch" + cz check --rev-range "$default_branch"..HEAD fi ''; };