Skip to content

Commit

Permalink
Critical fix for version sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Aug 24, 2024
1 parent 55d8962 commit fc84d5e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions hooks/pluginable.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,20 +604,24 @@ public function find_latest_repo_tag( $url ) {
$command = "git ls-remote --tags --sort=\"version:refname\" $url";
$output = explode( PHP_EOL, shell_exec( $command ) );

// Extract the last column into an array
$tags = array();
// Extract version numbers
$versions = [];
foreach ($output as $line) {
$columns = preg_split('/\s+/', $line);
$tag = end($columns);
if ( trim( $tag ) != "" ) {

// Clean line by obtaining everything to the right of last /
$tag = $this->getRightMost( $tag, "/" );
$tags[] = $tag;
// Omit $line if it contains the word beta
if (strpos($line, 'beta') !== false) {
continue;
}
if (preg_match('/refs\/tags\/(v?[0-9]+\.[0-9]+\.[0-9]+)/', $line, $matches)) {
$versions[] = $matches[1];
}
}
$latestRelease = end( $tags );
$this->log( 'Found latest release tag: ' . $latestRelease );

// Sort version numbers
usort($versions, 'version_compare');

// Get the most recent version number
$latestRelease = end($versions);
return $latestRelease;
}

Expand Down

0 comments on commit fc84d5e

Please sign in to comment.