Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a new increment script for assertion ids with b prefix
  • Loading branch information
gsmet authored and gunnarmorling committed Jun 30, 2017
1 parent b581146 commit 35f13d4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/src/scripts/increment-assertion-ids-with-b-prefix.sh
@@ -0,0 +1,35 @@
#! /bin/bash

# This is a simple script to increment assertion ids when one assertion
# is inserted, causing all the assertions to be incremented by 1.
# Note that it is a rather naive script for now: it only deals with
# +1 increments of assertions starting with 'a' and doesn't support
# wrapping around to b.

LC_ALL=C

if [ $# -ne 3 ]; then
echo "Usage: $0 <section> <start letter> <end letter>"
exit 1
fi

section=$1
start_letter=$2
end_letter=$3

if [[ $start_letter != [a-y] ]] ; then
echo "Start letter must be between a and y"
fi
if [[ $end_letter != [${start_letter}-y] ]] ; then
echo "End letter must be between a and y"
fi

for letter in $(eval echo "{${end_letter}..${start_letter}}"); do
next_letter=$(echo "$letter" | tr "_a-z" "a-z_")
pattern='@SpecAssertion(section = Sections.'${section}', id = "b'${letter}'")'
replacement='@SpecAssertion(section = Sections.'${section}', id = "b'${next_letter}'")'

for file in `grep -lr "${pattern}" src/main/java`; do
sed -i "s/${pattern}/${replacement}/g" ${file}
done
done

0 comments on commit 35f13d4

Please sign in to comment.