mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Merge remote-tracking branch 'origin/v3-feat/check-update' into v3-feat/check-update
This commit is contained in:
commit
7cedd45567
@ -13,7 +13,7 @@ interface CheckUpdateInterface
|
||||
*
|
||||
* @param string $name the name of the artifact
|
||||
* @param array $config the configuration for the artifact
|
||||
* @param string $old_version old version or identifier of the artifact to compare against
|
||||
* @param null|string $old_version old version or identifier of the artifact to compare against
|
||||
* @param ArtifactDownloader $downloader the artifact downloader instance
|
||||
*/
|
||||
public function checkUpdate(string $name, array $config, ?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult;
|
||||
|
||||
@ -21,7 +21,8 @@ class Git implements DownloadTypeInterface, CheckUpdateInterface
|
||||
// direct branch clone
|
||||
if (isset($config['rev'])) {
|
||||
default_shell()->executeGitClone($config['url'], $config['rev'], $path, $shallow, $config['submodules'] ?? null);
|
||||
$hash_result = shell(false)->execWithResult(SPC_GIT_EXEC . ' -C ' . escapeshellarg($path) . ' rev-parse HEAD');
|
||||
$shell = PHP_OS_FAMILY === 'Windows' ? cmd(false) : shell(false);
|
||||
$hash_result = $shell->execWithResult(SPC_GIT_EXEC . ' -C ' . escapeshellarg($path) . ' rev-parse HEAD');
|
||||
$hash = ($hash_result[0] === 0 && !empty($hash_result[1])) ? trim($hash_result[1][0]) : '';
|
||||
$version = $hash !== '' ? "dev-{$config['rev']}+{$hash}" : "dev-{$config['rev']}";
|
||||
return DownloadResult::git($name, $config, extract: $config['extract'] ?? null, version: $version, downloader: static::class);
|
||||
|
||||
@ -27,7 +27,7 @@ class PIE implements DownloadTypeInterface, CheckUpdateInterface
|
||||
$filename = "{$name}-{$version}." . ($dist_type === 'zip' ? 'zip' : 'tar.gz');
|
||||
$path = DOWNLOAD_PATH . DIRECTORY_SEPARATOR . $filename;
|
||||
default_shell()->executeCurlDownload($dist_url, $path, retries: $downloader->getRetry());
|
||||
return DownloadResult::archive($filename, $config, $config['extract'] ?? null, downloader: static::class);
|
||||
return DownloadResult::archive($filename, $config, $config['extract'] ?? null, version: $version, downloader: static::class);
|
||||
}
|
||||
|
||||
public function checkUpdate(string $name, array $config, ?string $old_version, ArtifactDownloader $downloader): CheckUpdateResult
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user