diff --git a/scripts/commit-hash.sh b/scripts/commit-hash.sh index 19235faea..53374dc39 100755 --- a/scripts/commit-hash.sh +++ b/scripts/commit-hash.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -# This script show the current Git branch and commit of the recipe source +# This script shows the current Git branch and commit of the recipe source + +set -e if [ $# -ne 1 ] then @@ -9,7 +11,41 @@ then exit 1 fi -recipe_path="$(target/release/find_recipe $1)" +recipe_name="$1" -cd "$recipe_path"/source +# Find the recipe directory +recipe_dir=$(find recipes -maxdepth 4 -type d -name "$recipe_name" | head -n 1) + +if [ -z "$recipe_dir" ] +then + echo "Error: Recipe '$recipe_name' not found" + exit 1 +fi + +# Check if source directory exists +source_dir="$recipe_dir/source" + +if [ ! -d "$source_dir" ] +then + echo "Error: Source directory for recipe '$recipe_name' not found at $source_dir" + echo "Note: The recipe may not have been fetched yet. Try running: make f.$recipe_name" + exit 1 +fi + +# Check if it's a git repository +if [ ! -d "$source_dir/.git" ] +then + echo "Error: Source directory is not a git repository" + exit 1 +fi + +# Show git information +echo "Recipe: $recipe_name" +echo "Path: $source_dir" +echo "" +cd "$source_dir" +echo "Branch and commit:" git branch -v +echo "" +echo "Latest commit:" +git log -1 --pretty=format:"Hash: %H%nAuthor: %an <%ae>%nDate: %ad%nMessage: %s%n" --date=iso