diff --git a/scripts/commit-hash.sh b/scripts/commit-hash.sh index 19235fae..50653af1 100755 --- a/scripts/commit-hash.sh +++ b/scripts/commit-hash.sh @@ -1,15 +1,27 @@ #!/usr/bin/env bash -# This script show the current Git branch and commit of the recipe source +# This script shows the current Git commit hash of system recipes at recipes/core -if [ $# -ne 1 ] +set -e + +# Check if recipes/core directory exists +if [ ! -d "recipes/core" ] then - echo "Usage: $0 recipe_name" - echo " Print the commit hash for recipe_name" + echo "Error: recipes/core directory not found" exit 1 fi -recipe_path="$(target/release/find_recipe $1)" - -cd "$recipe_path"/source -git branch -v +# Iterate through all system recipes in recipes/core +for recipe_dir in recipes/core/*/ +do + recipe_name=$(basename "$recipe_dir") + source_dir="$recipe_dir/source" + + # Check if source directory exists and is a git repository + if [ -d "$source_dir" ] && [ -d "$source_dir/.git" ] + then + # Get the commit hash + commit_hash=$(cd "$source_dir" && git rev-parse HEAD) + echo "$recipe_name: $commit_hash" + fi +done