2021-02-16 04:13:35 +08:00
#!/usr/bin/env bash
2019-01-09 05:52:22 +08:00
# This script is a developer tool, to be used by maintainers
# to update '@since TODO' entries with actual Jenkins release versions.
2020-03-16 21:20:54 +08:00
set -o errexit
set -o nounset
set -o pipefail
2019-01-09 05:52:22 +08:00
2019-10-16 18:22:47 +08:00
me = " $( basename " $0 " ) "
2019-01-09 05:52:22 +08:00
2021-02-16 04:13:35 +08:00
# Needs bash 4+
declare -A commitsAndTags
2019-01-09 05:52:22 +08:00
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 )
2019-01-09 05:52:22 +08:00
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 )
2019-01-09 05:52:22 +08:00
echo -e " \tfirst sha: $lineSha "
2020-03-16 21:20:54 +08:00
firstTag = $( git tag --sort= creatordate --contains " $lineSha " 'jenkins-*' | head -1 )
2019-01-09 05:52:22 +08:00
2019-10-16 18:22:47 +08:00
if [ [ -n $firstTag ] ] ; then
2019-01-09 05:52:22 +08:00
echo -e " \tfirst tag was $firstTag "
2021-02-16 04:13:35 +08:00
commitsAndTags[ $lineSha ] = " $firstTag "
2019-01-09 05:52:22 +08:00
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 "
2019-10-16 18:23:01 +08:00
rm -f " $file .bak "
2019-01-09 05:52:22 +08:00
else
2020-03-16 21:20:54 +08:00
echo -e "\tNot updating file, no tag found. Normal if the associated PR/commit is not merged and released yet; otherwise make sure to fetch tags from jenkinsci/jenkins"
2019-01-09 05:52:22 +08:00
fi
done
2021-02-16 04:13:35 +08:00
if [ [ " ${# commitsAndTags [@] } " -gt 0 ] ] ; then
echo ''
echo "List of commits introducing new API and the first release they went in:"
declare -A releases
for commit in " ${ !commitsAndTags[@] } " ; do
release = " ${ commitsAndTags [ $commit ] } "
releases[ $release ] = 1
done
mapfile -t sortedReleases < <( sort <<< " ${ !releases[*] } " )
for release in " ${ sortedReleases [@] } " ; do
echo " * https://github.com/jenkinsci/jenkins/releases/tag/ ${ release } "
for commit in " ${ !commitsAndTags[@] } " ; do
firstRelease = " ${ commitsAndTags [ $commit ] } "
if [ [ " $release " = " $firstRelease " ] ] ; then
echo " - https://github.com/jenkinsci/jenkins/commit/ $commit "
fi
done
done
fi