Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
b581146
commit 35f13d4
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
tests/src/scripts/increment-assertion-ids-with-b-prefix.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |