[master] 5c56bd1a2 save vmod developer life time
Nils Goroll
nils.goroll at uplex.de
Fri Sep 13 12:27:05 UTC 2019
commit 5c56bd1a22b87ca794c149bd807bc2692c365606
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Sep 13 13:55:40 2019 +0200
save vmod developer life time
by providing a trivial tool to rename vmod RST references.
To @Dridi and all other ladybug-lovers: I tried, but gave up after 5'.
Maybe spatch on its own would have done the job, but sed is just so much
simpler and, IMHO, totally appropriate for the job.
diff --git a/doc/changes.rst b/doc/changes.rst
index 5a12b171e..9f6208035 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -86,6 +86,8 @@ APIs / VMODs
:ref:`name.obj()`
:ref:`xobj.method()`
+ ``tools/vmod_ref_rename.sh`` is provided to automate this task
+
================================
Varnish Cache 6.2.0 (2019-03-15)
================================
diff --git a/tools/vmod_ref_rename.sh b/tools/vmod_ref_rename.sh
new file mode 100755
index 000000000..ecf0091ee
--- /dev/null
+++ b/tools/vmod_ref_rename.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# trivial sed-based tool to rename RST references in vmod .vcc files
+# to the new scheme as of commit
+# 904ceabf07c294983efcebfe1d614c2d2fd5cdda
+#
+# only tested with GNU sed
+#
+# to be called from a vmod git repository
+#
+# Author: Nils Goroll <nils.goroll at uplex.de>
+#
+# This file is in the public domain
+
+typeset -ra files=($(git ls-files | grep -E '\.vcc$'))
+
+if [[ ${#files[@]} -eq 0 ]] ; then
+ echo >&2 'No vcc files found'
+ exit 0
+fi
+
+if [[ -n $(git status -s) ]] ; then
+ echo >&2 'clean up your tree first'
+ git status
+ exit 1
+fi
+
+set -eu
+
+sed -e 's#`vmod_\([^.]*\)\.\([^.`]*\)`_#`\1.\2()`_#g' \
+ -e 's#`vmod_\([^.]*\)\.\([^.`]*\).\([^.`]*\)`_#`x\2.\3()`_#g' \
+ -i "${files[@]}"
+
+if [[ -z $(git status -s) ]] ; then
+ echo >&2 'no change'
+ exit 0
+fi
+
+git commit -m 'rename vmod RST references (vmod_ref_rename.sh)' \
+ "${files[@]}"
+
+echo DONE - review and test the previous commit
More information about the varnish-commit
mailing list