Resolve relative hooks.path against $site_path, not cwd of the process When hooks.path was given as relative path it got resolved against the current working directory of the Gerrit process. While it may often be the case that the current working directory of Gerrit process is the $site_path, it is not guaranteed and, depending how Gerrit is started, it may be some other directory. Most, if not all, of the relative paths in gerrit.config are resolved against the $site_path and we should do the same for the hooks.path. Release-Notes: Resolve relative hooks.path against $site_path Change-Id: Ie72c0657393e1dfe078155e27edbd4c0412892e6
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java index f415e90..ea69cfc 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java +++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java
@@ -48,7 +48,7 @@ String v = config.getString("hooks", null, "path"); if (v != null) { - this.hooksPath = Path.of(v); + this.hooksPath = sitePaths.resolve(v); } else { this.hooksPath = sitePaths.hooks_dir; }
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md index 2aea566..c5698be 100644 --- a/src/main/resources/Documentation/config.md +++ b/src/main/resources/Documentation/config.md
@@ -32,6 +32,7 @@ hooks.path : Location of hook executables. If not set, defaults to `$site_path/hooks` + When given as relative path, resolved against the `$site_path`. hooks.syncHookTimeout : Timeout value in seconds for synchronous hooks. If not set, defaults