Skip to content

Commit

Permalink
Null 'fixed' field if target not a 'done' status (#3)
Browse files Browse the repository at this point in the history
When transitioning a task to a non-Done status, we don't want to set the Fixed field to anything, and want to clear it if it was already set.

Fix #2
  • Loading branch information
parnic authored Aug 10, 2023
1 parent 4e8faae commit d6be918
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static function handleSmartCommitMessage($item, ServiceLocator $services)
$services);

$transitionId = null;
$transitionToStatusType = null;
if ($availableTransitions && is_array($availableTransitions) && array_key_exists('transitions', $availableTransitions)
&& is_array($availableTransitions['transitions'])) {
foreach ($availableTransitions['transitions'] as $availableTransition) {
Expand All @@ -98,6 +99,10 @@ public static function handleSmartCommitMessage($item, ServiceLocator $services)

if (strpos($availableTransitionName, $transitionCommand['command']) === 0) {
$transitionId = $availableTransition['id'];

if (isset($availableTransition['to']) && isset($availableTransition['to']['statusCategory'])) {
$transitionToStatusType = $availableTransition['to']['statusCategory']['key'];
}
break;
}
}
Expand Down Expand Up @@ -150,6 +155,15 @@ public static function handleSmartCommitMessage($item, ServiceLocator $services)
if ($clFieldNumeric) {
$clObj = array($clField => $item->getId());
}

// if this isn't a "done" transition, make sure the fixed field is nulled out
if ($transitionToStatusType && $transitionToStatusType !== 'done') {
$logger->debug("JiraSmartCommits: nulling changelist field value because target status is not a Done status (is {$transitionToStatusType}).");
$clObj = array($clField => null);
} else {
$logger->debug("JiraSmartCommits: desired status is a 'done' status type, continuing with setting fixed field to {$item->getId()}.");
}

$msg = array(
'fields' => $clObj,
);
Expand Down

0 comments on commit d6be918

Please sign in to comment.