jenkins/update-since-todo.sh

33 lines
993 B
Bash
Raw Normal View History

#!/bin/bash
# This script is a developer tool, to be used by maintainers
# to update '@since TODO' entries with actual Jenkins release versions.
set -euo pipefail
2019-10-16 18:22:47 +08:00
me="$( basename "$0" )"
IFS=$'\n'
for todo in $( git grep --line-number '@since TODO' | grep -v "$me" )
do
#echo "TODO: $todo"
2019-10-16 18:22:47 +08:00
file=$( echo "$todo" | cut -d : -f 1 )
line=$( echo "$todo" | cut -d : -f 2 )
echo "Analyzing $file:$line"
2019-10-16 18:22:47 +08:00
lineSha=$( git blame --porcelain -L "$line,$line" "$file" | head -1 | cut -d ' ' -f 1 )
echo -e "\tfirst sha: $lineSha"
2019-10-16 18:22:47 +08:00
firstTag=$( git tag --sort=creatordate --contains "$lineSha" | head -1 )
2019-10-16 18:22:47 +08:00
if [[ -n $firstTag ]]; then
echo -e "\tfirst tag was $firstTag"
echo -e "\tUpdating file in place"
sedExpr="${line}s/@since TODO/@since ${firstTag//jenkins-/}/"
2019-10-16 18:22:47 +08:00
sed -i.bak "$sedExpr" "$file"
else
echo -e "\tNot updating file, no tag found. Normal if the associated PR/commit is not merged and released yet"
fi
done