Skip to content

Commit

Permalink
+ addTagLinks normalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Dec 11, 2016
1 parent 66f9b54 commit 6517a9e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,3 +23,6 @@ hiqdev/chkipper
[Development started]: https://github.com/hiqdev/chkipper/releases
[@hiqsol]: https://github.com/hiqsol
[sol@hiqdev.com]: https://github.com/hiqsol
[0.0.3]: https://github.com/hiqdev/chkipper/compare/0.0.3..0.0.2
[0.0.2]: https://github.com/hiqdev/chkipper/compare/0.0.2..0.0.1
[0.0.1]: https://github.com/hiqdev/chkipper/releases/tag/0.0.1
3 changes: 3 additions & 0 deletions history.md
Expand Up @@ -158,3 +158,6 @@ hiqdev/chkipper
[a4da4ba]: https://github.com/hiqdev/chkipper/commit/a4da4ba
[e03f6d8]: https://github.com/hiqdev/chkipper/commit/e03f6d8
[ea103f6]: https://github.com/hiqdev/chkipper/commit/ea103f6
[0.0.3]: https://github.com/hiqdev/chkipper/compare/0.0.3..0.0.2
[0.0.2]: https://github.com/hiqdev/chkipper/compare/0.0.2..0.0.1
[0.0.1]: https://github.com/hiqdev/chkipper/releases/tag/0.0.1
25 changes: 25 additions & 0 deletions src/history/History.php
Expand Up @@ -270,6 +270,7 @@ public function normalize($options = [])
'addInitTag' => [],
'setTagDates' => [],
'addCommitLinks' => [],
'addTagLinks' => [],
'removeCommitLinks' => [],
'prettifyUserLinks' => [],
];
Expand Down Expand Up @@ -338,6 +339,30 @@ public function setTagDates()
}
}

/**
* Adds tag links.
*/
public function addTagLinks()
{
$prev = null;
foreach (array_keys($this->getTags()) as $tag) {
if ($prev && !$this->hasLink($prev)) {
$this->addLink($prev, $this->generateTagHref($prev, $tag));
}
$prev = $tag;
}
}

public function generateTagHref($prev, $curr)
{
$project = $this->getProject();
if ($curr == $this->initTag) {
return "https://github.com/$project/releases/tag/$prev";
}

return "https://github.com/$project/compare/$prev..$curr";
}

/**
* Adds links for commits not having ones.
*/
Expand Down

0 comments on commit 6517a9e

Please sign in to comment.