Skip to content

Commit b9e1ea1

Browse files
author
Robert Bittle
authored
Merge pull request #76 from guywithnose/jiraLinks
Add jira links
2 parents 07ab29e + 8c4cec9 commit b9e1ea1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/Change/Change.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class Change implements ChangeInterface
1313
/** @type string A message describing the change. */
1414
protected $_message;
1515

16+
/** @type string A link to the change. */
17+
protected $_link = '';
18+
1619
/**
1720
* Initialize the change.
1821
*
@@ -47,6 +50,28 @@ public function getType() : Type
4750
return $this->_type;
4851
}
4952

53+
/**
54+
* Sets the link.
55+
*
56+
* @param string $link The link
57+
*
58+
* @return void
59+
*/
60+
public function setLink(string $link)
61+
{
62+
$this->_link = $link;
63+
}
64+
65+
/**
66+
* Get the link.
67+
*
68+
* @return string The link.
69+
*/
70+
public function getLink() : string
71+
{
72+
return $this->_link;
73+
}
74+
5075
/**
5176
* Get the displayable type.
5277
*
@@ -64,6 +89,10 @@ public function displayType()
6489
*/
6590
public function displayShort() : string
6691
{
92+
if (!empty($this->getLink())) {
93+
return '* [' . strtok($this->_message, "\n") . "]({$this->getLink()})";
94+
}
95+
6796
return '* ' . strtok($this->_message, "\n");
6897
}
6998

src/Change/ChangeInterface.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ public function setType(Type $type);
2121
*/
2222
public function getType() : Type;
2323

24+
/**
25+
* Sets the link.
26+
*
27+
* @param string $link The link
28+
*
29+
* @return void
30+
*/
31+
public function setLink(string $link);
32+
33+
/**
34+
* Get the link.
35+
*
36+
* @return string The link.
37+
*/
38+
public function getLink() : string;
39+
2440
/**
2541
* Returns a short markdown snippet of the change for use in release notes.
2642
*

src/Type/JiraTypeSelector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function getChangeType(ChangeInterface $change) : Type
5555
$issuetype = $issue->fields->issuetype->name;
5656
$type = $this->_typeManager->getTypeByName($issuetype);
5757
if ($type !== null) {
58+
$host = $this->_issueService->getConfiguration()->getJiraHost();
59+
$change->setLink("{$host}/browse/{$key}");
5860
return $type;
5961
}
6062
} catch (JiraException $e) {

0 commit comments

Comments
 (0)