File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -604,20 +604,24 @@ public function find_latest_repo_tag( $url ) {
604604 $ command = "git ls-remote --tags --sort= \"version:refname \" $ url " ;
605605 $ output = explode ( PHP_EOL , shell_exec ( $ command ) );
606606
607- // Extract the last column into an array
608- $ tags = array () ;
607+ // Extract version numbers
608+ $ versions = [] ;
609609 foreach ($ output as $ line ) {
610- $ columns = preg_split ('/\s+/ ' , $ line );
611- $ tag = end ($ columns );
612- if ( trim ( $ tag ) != "" ) {
613610
614- // Clean line by obtaining everything to the right of last /
615- $ tag = $ this ->getRightMost ( $ tag , "/ " );
616- $ tags [] = $ tag ;
611+ // Omit $line if it contains the word beta
612+ if (strpos ($ line , 'beta ' ) !== false ) {
613+ continue ;
614+ }
615+ if (preg_match ('/refs\/tags\/(v?[0-9]+\.[0-9]+\.[0-9]+)/ ' , $ line , $ matches )) {
616+ $ versions [] = $ matches [1 ];
617617 }
618618 }
619- $ latestRelease = end ( $ tags );
620- $ this ->log ( 'Found latest release tag: ' . $ latestRelease );
619+
620+ // Sort version numbers
621+ usort ($ versions , 'version_compare ' );
622+
623+ // Get the most recent version number
624+ $ latestRelease = end ($ versions );
621625 return $ latestRelease ;
622626 }
623627
You can’t perform that action at this time.
0 commit comments