Add submodule-update-foreach.sh and a post-pull hook for it
authorAntonio Ospite <ao2@ao2.it>
Mon, 17 Dec 2018 09:16:38 +0000 (10:16 +0100)
committerAntonio Ospite <ao2@ao2.it>
Mon, 17 Dec 2018 09:37:45 +0000 (10:37 +0100)
Update submodules also after a "vcsh pull" command.

This requires a whole new script because vcsh does not call post-pull
hooks after pulling each repositories, it only calls the hook once after
pulling all of them.

See https://github.com/RichiH/vcsh/issues/213

When the issue gets fixed submodule-update-foreach.sh can be removed and
post-pull.00-submodule-init can link to submodule-update.sh

.config/vcsh/hooks-available/submodule-update-foreach.sh [new file with mode: 0755]
.config/vcsh/hooks-enabled/post-pull.00-submodule-init [new symlink]

diff --git a/.config/vcsh/hooks-available/submodule-update-foreach.sh b/.config/vcsh/hooks-available/submodule-update-foreach.sh
new file mode 100755 (executable)
index 0000000..3405942
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+: "${XDG_CONFIG_HOME:="$HOME/.config"}"
+
+# XXX This should really be a normal post-pull hook, but vcsh lacks
+# per-repository pull/push hooks, see
+# https://github.com/RichiH/vcsh/issues/213
+
+echo "Updating submodules..."
+vcsh foreach -g "$XDG_CONFIG_HOME/vcsh/hooks-available/submodule-update.sh"
diff --git a/.config/vcsh/hooks-enabled/post-pull.00-submodule-init b/.config/vcsh/hooks-enabled/post-pull.00-submodule-init
new file mode 120000 (symlink)
index 0000000..5ebe104
--- /dev/null
@@ -0,0 +1 @@
+../hooks-available/submodule-update-foreach.sh
\ No newline at end of file