Skip to content

Commit

Permalink
Fix version compare bug in example plan
Browse files Browse the repository at this point in the history
  • Loading branch information
op-ct committed Jul 19, 2021
1 parent 1ce7881 commit 10d1266
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 3 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


<!--
## [Unreleased]

### Added
### Changed
### Fixed

### Removed
-->
* Fixed version comparison bug in example plan
`github_inventory::latest_semver_tags`


## [0.4.0]

Expand Down
7 changes: 3 additions & 4 deletions plans/latest_semver_tags.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@
Hash($kv_pairs)
}



$repos_latest_tag_data = $tag_resultset.ok_set.map |$r| {
# Find highest SemVer-ish (1.2.3, v1.2.3, 1.2.3-4) tag
$tag = ($r.value['body'].map |$x| { $x['name'] }).filter |$x| {
$x =~ /^v?\d+\.\d+\.\d+(-\d+)?$/
}.max |$a, $b| {
$semver_a = SemVer($a.regsubst(/^v/,'').regsubst(/-\d+$/,'')) # voxpupuli-style `v<SemVer>`
$semver_b = SemVer($a.regsubst(/^v/,'').regsubst(/-\d+$/,'')) # RPM-style `-<release number>`
# Normalize voxpupuli-style `v<SemVer>` and RPM-style `-<release number>`
$semver_a = SemVer($a.regsubst(/^v/,'').regsubst(/-\d+$/,''))
$semver_b = SemVer($b.regsubst(/^v/,'').regsubst(/-\d+$/,''))
compare($semver_a, $semver_b)
}

Expand Down

0 comments on commit 10d1266

Please sign in to comment.