diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:43:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:43:47 +0000 |
commit | becaa47e20d6c121329adaf9b3f80c1203420df0 (patch) | |
tree | 929ea67632da3cbaca35b156e2bf707dc421ecc2 /contrib | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-fileshipper-becaa47e20d6c121329adaf9b3f80c1203420df0.tar.xz icingaweb2-module-fileshipper-becaa47e20d6c121329adaf9b3f80c1203420df0.zip |
Adding upstream version 1.2.0.upstream/1.2.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/git-hooks/post-merge | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/git-hooks/post-merge b/contrib/git-hooks/post-merge new file mode 100755 index 0000000..ae59a5c --- /dev/null +++ b/contrib/git-hooks/post-merge @@ -0,0 +1,35 @@ +#/usr/bin/env bash +# Trigger Director config rendering when something changed + +# This is a git hook that will run after `git pull`. In case any file was +# changed it will instruct Director to re-render the current configuration. +# +# Add this file to your git working directory as `.git/hooks/post-merge`. It +# has to executable (`chmod +x`), otherwise it wouldn't run. The `icingacli` +# has to be on your `PATH` when running `git pull`. +# +# TODO: verify whether HEAD@{1} instead of ORIG_HEAD should be preferred + +changed_files() { + git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD +} + +had_changes() { + local changed_lines=$(changed_files | wc -l) + if [ "$changed_lines" -gt "0" ]; then + return 0 + else + return 1 + fi +} + +render_director_config() { + `icingacli director config render` +} + +run_if() { + $1 && eval "$2" +} + +run_if had_changes render_director_config + |