Skip to content

Commit

Permalink
chore: git rev-parse not reliable in github-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaraj-bh committed Sep 23, 2024
1 parent 476a948 commit 813c246
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
};
Expand Down

0 comments on commit 813c246

Please sign in to comment.