Harmonize action names with names used in hooks-its * "status" -> "set-status" * "resolution" -> "set-resolution" * "status/resolution" -> "set-status-and-resolution" The old action names still work but will get removed. Change-Id: I5563c4e10a4148ba5447ecb098b6482a51d08ae5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/bz/BugzillaClient.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/bz/BugzillaClient.java index aa38f85..770ed96 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/hooks/bz/BugzillaClient.java +++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/bz/BugzillaClient.java
@@ -103,17 +103,27 @@ } } - public void performAction(final String bugId, final String actionName, - final String actionValue) throws BugzillaException, + public void performAction(final String bugId, final String actionNameParam, + final String actionValueParam) throws BugzillaException, InvalidTransitionException { Bug bug = getBug(bugId); + + String actionName = actionNameParam; + if (actionName.startsWith("set-")) { + actionName = actionName.substring(4); + } + actionName = actionName.replaceAll("-and-", "/"); + + String actionValue = actionValueParam; + actionValue = actionValue.replaceAll(" ", "/"); + if ("status".equals(actionName) || "resolution".equals(actionName)) { performSimpleActionChainable(bug, actionName, actionValue); } else if ("status/resolution".equals(actionName)) { performChainedAction(bug, actionName, actionValue); } else { - throw new InvalidTransitionException("Action " + actionName + " is not" - + " known"); + throw new InvalidTransitionException("Action " + actionNameParam + + " is not known"); } connector.executeMethod(new UpdateBug(bug)); }
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md index f80859c..592b992 100644 --- a/src/main/resources/Documentation/config.md +++ b/src/main/resources/Documentation/config.md
@@ -515,11 +515,11 @@ adds a rendered Velocity template as issue comment. <<action-log-event,log-event>>:: appends the event's properties to gerrit's log. -<<action-resolution,resolution>>:: +<<action-set-resolution,set-resolution>>:: sets the resolution of the issue -<<action-status,status>>:: +<<action-set-status,set-status>>:: sets the status of the issue -<<action-status-resolution,status/resolution>>:: +<<action-set-status-and-resolution,set-status-and-resolution>>:: sets the status of the issue Further actions may be provided by 'hooks-its' based plugins. @@ -627,47 +627,46 @@ This action is useful, when testing rules or trying to refine conditions on rules, as it make the available properties visible. -[[action-resolution]] -Action: resolution -^^^^^^^^^^^^^^^^^^ +[[action-set-resolution]] +Action: set-resolution +^^^^^^^^^^^^^^^^^^^^^^ -The 'resolution' action sets the issue's resolution. The first parameter is -the resolution to set. So for example +The 'set-resolution' action sets the issue's resolution. The first +parameter is the resolution to set. So for example ---- -action = resolution WORKSFORME +action = set-resolution WORKSFORME ---- sets the issue's status to WORKSFORME. If you want to set the status and the resolution, use the -'status/resolution' action, so you can set both status and resolution -in one go. +'set-status-and-resolution' action, so you can set both status and +resolution in one go. -[[action-status]] -Action: status -^^^^^^^^^^^^^^ +[[action-set-status]] +Action: set-status +^^^^^^^^^^^^^^^^^^ -The 'status' action sets the issue's status. The first parameter is -the status to set. So for example +The 'set-status' action sets the issue's status. The first parameter +is the status to set. So for example ---- -action = status CONFIRMED +action = set-status CONFIRMED ---- sets the issue's status to CONFIRMED. If you want to set the status to a value that also requires a -resolution, use the 'status/resolution' action, so you can set both -status and resolution in one go. +resolution, use the 'set-status-and-resolution' action, so you can set +both status and resolution in one go. -[[action-status-resolution]] -Action: status/resolution -^^^^^^^^^^^^^^^^^^^^^^^^^ +[[action-set-status-and-resolution]] +Action: set-status-and-resolution +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The 'status/resolution' action sets both the issue's status and it's -resolution in one go. The first parameter is of the form -'STATUS/RESOLUTION' and sets the status to 'STATUS' and the resolution -to 'RESOLUTION'. +The 'set-status-and-resolution' action sets both the issue's status +and it's resolution in one go. The first parameter denotes the status +to set, the second parameter denotes the resolution to set. So for example ---- -action = status/resolution RESOLVED/FIXED +action = set-status-and-resolution RESOLVED FIXED ---- sets the issue's status to RESOLVED and it's resolution to FIXED.