Skip to content

Commit b71251b

Browse files
committed
build: 🧑‍💻 check if there are commits on the branch before checking commits
1 parent f1f9009 commit b71251b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

justfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ build-website:
3131
# Run checks on commits with non-main branches
3232
check-commits:
3333
#!/bin/zsh
34-
if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]
34+
branch_name=$(git rev-parse --abbrev-ref HEAD)
35+
number_of_commits=$(git rev-list --count HEAD ^$branch_name)
36+
if [[ ${branch_name} != "main" && ${number_of_commits} -gt 0 ]]
3537
then
3638
poetry run cz check --rev-range main..HEAD
39+
else
40+
echo "Not on main or haven't committed yet."
3741
fi

0 commit comments

Comments
 (0)