From 0861ed9d1ff816aae6d973f67ce85f1fbf9afecf Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Wed, 25 Feb 2015 10:58:49 -0800 Subject: [PATCH] Fix minor bugs in ChangeHookRunner Treat empty hook values as missing, rather than executing the path called "". Use changeMergedHook instead of changeMerged, to match the rest of the hooks and the documentation. Change-Id: Ide7ddd57d5ef3f45dad815d9bf7c4cda76c49f6c --- .../main/java/com/google/gerrit/common/ChangeHookRunner.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/common/ChangeHookRunner.java b/gerrit-server/src/main/java/com/google/gerrit/common/ChangeHookRunner.java index 086a6d02e2..8bd082d03e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/common/ChangeHookRunner.java +++ b/gerrit-server/src/main/java/com/google/gerrit/common/ChangeHookRunner.java @@ -14,6 +14,7 @@ package com.google.gerrit.common; +import com.google.common.base.Strings; import com.google.common.collect.Sets; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.gerrit.common.data.ContributorAgreement; @@ -263,7 +264,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher, draftPublishedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "draftPublishedHook", "draft-published")).getPath()); commentAddedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "commentAddedHook", "comment-added")).getPath()); changeMergedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "changeMergedHook", "change-merged")).getPath()); - mergeFailedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "mergeFailed", "merge-failed")).getPath()); + mergeFailedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "mergeFailedHook", "merge-failed")).getPath()); changeAbandonedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "changeAbandonedHook", "change-abandoned")).getPath()); changeRestoredHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "changeRestoredHook", "change-restored")).getPath()); refUpdatedHook = sitePath.resolve(new File(hooksPath, getValue(config, "hooks", "refUpdatedHook", "ref-updated")).getPath()); @@ -300,7 +301,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher, */ private String getValue(final Config config, final String section, final String setting, final String fallback) { final String result = config.getString(section, null, setting); - return (result == null) ? fallback : result; + return Strings.isNullOrEmpty(result) ? fallback : result; } /**