Unify tags (fixes #827) #945

Merged
max.mehl merged 12 commits from jzarl/fsfe-website:issue/827 into master 2019-05-27 11:44:30 +00:00
2 changed files with 17 additions and 3 deletions
Showing only changes of commit 513b377d56 - Show all commits

View File

@ -33,4 +33,6 @@ You can then fill the "action" field with the following actions:
A word of warning: you'll probably need to polish the results by hand a little
(removing empty lines, checking for duplicate tags introduced by renaming).
## Debugging
You can call tagtool.sh with the environment variable "VERBOSE" set to 1.

View File

@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
###
TAGSDATAFILE="$1"
if [[ ! -f "$1" ]]
then
@ -23,6 +22,19 @@ then
exit 1
fi
# set to "1" to add verbose debug outpu
VERBOSE=${VERBOSE:-0}
doVerbose()
# doVerbose CMD ARGS..
{
if [[ VERBOSE -eq 1 ]]
then
echo "${@@Q}" >&2
fi
"$@"
}
findTaggedFiles()
# findTaggedFiles TAG_ID
# grep for files containing the tag
@ -41,7 +53,7 @@ renameTag()
for f in $(findTaggedFiles "$oldTagId")
do
echo "..$f" >&2
if ! sed -E -i "s;>\W*$oldTagId\W*</tag>;>$newTagId</tag>;" "$f"
if ! doVerbose sed -E -i "s;>\W*$oldTagId\W*</tag>;>$newTagId</tag>;" "$f"
then
echo "ERROR!" >&2
return 1
@ -59,7 +71,7 @@ removeTag()
for f in $(findTaggedFiles "$oldTagId")
do
echo "..$f" >&2
if ! sed -E -i "s;\W*<tag\W*content=\"[^\"]*\"\W*>\W*$TagId\W*</tag>\W*;;i" "$f"
if ! doVerbose sed -E -i "s;\W*<tag\W*content=\"[^\"]*\"\W*>\W*$TagId\W*</tag>\W*;;i" "$f"
then
echo "ERROR!" >&2
return 1