From 813c246c3ce9605f5a8c2f16f0812806ad581c5c Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 24 Sep 2024 05:13:23 +0530 Subject: [PATCH] chore: git rev-parse not reliable in github-runner --- dev/flake.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 ''; };