diff --git a/versioncontrol_project.module b/versioncontrol_project.module index 22b2dea..18155e8 100644 --- a/versioncontrol_project.module +++ b/versioncontrol_project.module @@ -511,7 +511,7 @@ function versioncontrol_project_versioncontrol_entity_commit_insert(Versioncontr // Look for a commit operation being inserted that has an issue reference in // the commit message to a valid project issue node. - if ($operation->type == VERSIONCONTROL_OPERATION_COMMIT && preg_match_all('/#(\d+)/', $operation['message'], $matches, PREG_SET_ORDER)) { + if ($operation->type == VERSIONCONTROL_OPERATION_COMMIT && preg_match_all('/#(\d+)\b/', $operation->message, $matches, PREG_SET_ORDER)) { // Allow for multiple issue references to be made in a single commit. foreach ($matches as $match) { if (($node = node_load($match[1])) && $node->type == 'project_issue') { @@ -519,25 +519,42 @@ function versioncontrol_project_versioncontrol_entity_commit_insert(Versioncontr $changes = array( 'nid' => $node->nid, ); + $url_handler = $operation->repository->getUrlHandler(); + $label_names = array(); + foreach ($operation->labels as $label) { + $label_names = $label->name; + } $placeholders = array( - '!revision' => $operation->formatRevisionIdentifier('short'), // @TODO Need to print link, assume helper function? - '@labels' => implode(', ', $operation->labels), // @TODO Need to access ->name, possibly an existing helper function? + '!revision' => $url_handler->getCommitViewUrl($operation->revision), + '@labels' => implode(', ', $label_names), '@message' => $operation->message, ); // If the Drupal user is known then format the author as a link and post // the comment as the detected user. Otherwise format the author as the - // VCS username without a link and post as the auto-followup user. + // VCS committer without a link and post as the auto-followup user. if ($operation->committer_uid) { - $placeholders['!committer'] = l($operation->committer, 'user/' . $operation->committer_uid); - $changes['comment'] = t('Commit !revision on @labels by !committer: "@message"', $placeholders); + $committer = new stdClass(); + $committer->uid = $operation->committer_uid; + $committer->name = check_plain($operation->committer); + $placeholders['!committer'] = theme('username', $committer); + if ($operation->author_uid == $operation->committer_uid) { + $changes['comment'] = t('Commit !revision on @labels by !committer:
@message', $placeholders); + } + else { + $author = new stdClass(); + $author->uid = $operation->author_uid; + $author->name = check_plain($operation->author); + $placeholders['!author'] = theme('username', $author); + $changes['comment'] = t('Commit !revision on @labels authored by !author, committed by !committer:
@message', $placeholders); + } $changes['uid'] = $operation->committer_uid; project_issue_add_followup($changes); } else { $placeholders['!committer'] = $operation->committer; - $changes['comment'] = t('Commit !revision on @labels by !committer: "@message"', $placeholders); + $changes['comment'] = t('Commit !revision on @labels by !committer:
@message"', $placeholders); project_issue_add_auto_followup($changes); }