redox/scripts/commit-hash.sh
Ojus Chugh 7439b49cdd Add commit-hash.sh for recipe troubleshooting
Signed-off-by: Ojus Chugh <ojuschugh@gmail.com>
2025-12-19 01:07:55 +05:30

52 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# This script shows the current Git branch and commit of the recipe source
set -e
if [ $# -ne 1 ]
then
echo "Usage: $0 recipe_name"
echo " Print the commit hash for recipe_name"
exit 1
fi
recipe_name="$1"
# 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