Skip to content

Commit

Permalink
Update plugins fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Aug 6, 2024
1 parent c61acb0 commit 55d8962
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions hooks/pluginable.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ function update_plugins() {
// Do a force reset on the repo to avoid merge conflicts, and obtain found latest version
$cmd = 'cd ' . $subfolder . ' && git reset --hard';
$cmd .= ' && git clean -f -d';
$cmd .= ' && git fetch --all';
$cmd .= ' && git clone --depth 1 --branch "' . $latest_version . '" ' . $url . ' 2>/dev/null';
$cmd .= ' && git fetch origin tag ' . $latest_version . ' && git checkout tags/' . $latest_version;
$this->log( 'Update ' . $subfolder . ' from ' . $installed_version . ' to ' . $latest_version);
$this->log( $cmd );
$this->log( shell_exec( $cmd ) );

// Run the update script if it exists
Expand Down Expand Up @@ -609,21 +609,14 @@ public function find_latest_repo_tag( $url ) {
foreach ($output as $line) {
$columns = preg_split('/\s+/', $line);
$tag = end($columns);
$tags[] = $tag;
}

// Clean the tags by removing preceding 'refs/tags/' if present
$cleanTags = array_map(function ($tag) {
$tag = str_replace('refs/tags/', '', $tag);
return $tag;
}, $tags);

// Filter out tags that don't conform to the pattern #.#.#
$pattern = '/^\d+\.\d+\.\d+$/';
$finalTags = preg_grep($pattern, $cleanTags);
if ( trim( $tag ) != "" ) {

// Get the last element as a string
$latestRelease = end($finalTags);
// Clean line by obtaining everything to the right of last /
$tag = $this->getRightMost( $tag, "/" );
$tags[] = $tag;
}
}
$latestRelease = end( $tags );
$this->log( 'Found latest release tag: ' . $latestRelease );
return $latestRelease;
}
Expand Down

0 comments on commit 55d8962

Please sign in to comment.