Skip to content

Commit

Permalink
#13 Implement integration with GitHub
Browse files Browse the repository at this point in the history
 - Refactored "jira" in xpaths.
  • Loading branch information
andkirby committed Dec 1, 2015
1 parent 01fb5a5 commit a789743
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions LibHooks/lib/PreCommit/Filter/ShortCommitMsg/Jira/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Class filter to parse short message
*
* @package PreCommit\Validator
* @package PreCommit\Filter\ShortCommitMsg\Jira
*/
class Parser implements InterpreterInterface
{
Expand Down Expand Up @@ -156,11 +156,10 @@ protected function _getVerbs()
*
* @return string
* @throws \PreCommit\Exception
* @todo Refactor this 'cos it belongs to JIRA only
*/
protected function _getActiveIssueKey()
{
return $this->_getConfig()->getNode('tracker/jira/active_task');
return $this->_getConfig()->getNode('tracker/' . $this->_getTrackerType() . '/active_task');
}

/**
Expand All @@ -176,9 +175,9 @@ protected function _getActiveIssueKey()
protected function _normalizeIssueKey($issueNo)
{
if ((string)(int)$issueNo === $issueNo) {
$project = $this->_getConfig()->getNode('tracker/jira/project');
$project = $this->_getConfig()->getNode('tracker/' . $this->_getTrackerType() . '/project');
if (!$project) {
throw new Exception('JIRA project key is not set. Please add it to issue-key or add by XPath "jira/project" in project configuration file "commithook.xml" within current project.');
throw new Exception('JIRA project key is not set. Please add it to issue-key or add by XPath "tracker/jira/project" in project configuration file "commithook.xml" within current project.');
}
$issueNo = "$project-$issueNo";
}
Expand Down Expand Up @@ -358,4 +357,14 @@ protected function _getIssueKeyCompleteRegular()
{
return '[A-Z0-9]+[-][0-9]+';
}

/**
* Get tracker type
*
* @return string
*/
protected function _getTrackerType()
{
return (string)$this->_getConfig()->getNode('tracker/type');
}
}

0 comments on commit a789743

Please sign in to comment.