Skip to content

Commit

Permalink
whippet deps describe shows the most detailed semver version
Browse files Browse the repository at this point in the history
In our plugin repositories, we now tag commits with major
version tags, e.g. 'v1' and more detailed tags, e.g. 'v1.2.3'.

When we run 'whippet deps describe' we always want the
version number with the most fidelity.
  • Loading branch information
snim2 committed Jan 18, 2024
1 parent 44f42aa commit 8c30725
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- `whippet generate app` generates an app which can be deployed by Whippet.
- `whippet deps describe` always prints the most detailed semver version available.

### Added
- Support for PHP 8
Expand Down
4 changes: 4 additions & 0 deletions src/Git/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ public static function tag_for_commit($repo, $commit_hash)
return \Result\Result::ok('No tags for commit ' . $commit_hash);
}

usort($tags_array, function ($a, $b) {
return strlen($b) <=> strlen($a);
});

$resultArray = explode('/', $tags_array[0]);
$result = str_replace("^{}", "", end($resultArray));

Expand Down

0 comments on commit 8c30725

Please sign in to comment.