blob: 29ed5c13cf0fe0db0f7a2d4f94e7b3f787de6867 [file] [log] [blame]
#!/bin/bash
#
# Convert a gsd request file into an upstream git id to feed as a request
#
# Warning, almost no error checking, this is a hack to get things converted only.
#
txtred=$(tput setaf 1) # Red
txtgrn=$(tput setaf 2) # Green
txtblu=$(tput setaf 4) # Blue
txtcyn=$(tput setaf 6) # Cyan
txtrst=$(tput sgr0) # Text reset
in_file=$1
out_file=$2
for record in $(cat ${in_file}); do
stable_id=$(echo "${record}" | cut -f 3 -d ',')
echo "record='${txtblu}${record}${txtrst}'"
echo -n " stable_id='${txtcyn}${stable_id}${txtrst}' "
upstream=$(cd /home/gregkh/linux/next/ && git show ${stable_id} | grep -i upstream | head -n 1)
if [[ ${upstream} =~ [[:xdigit:]]{40} ]] ; then
upstream_id=${BASH_REMATCH[0]}
echo "upstream_id='${txtgrn}${upstream_id}${txtrst}'"
echo "${upstream_id}" >> ${out_file}
else
# This must be a non-stable id, so treat it as such
echo "${txtred}mainline id='${stable_id}'${txtrst}"
echo "${stable_id}" >> ${out_file}
fi
done