add git source: HIT
parent
4cfe38c388
commit
459b23b284
|
@ -388,34 +388,33 @@ function setConfigResponse($response)
|
|||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||
{
|
||||
$tmppath = '/tmp';
|
||||
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
if ($GitSource=='Github') {
|
||||
// 从github下载对应tar.gz,并解压
|
||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||
} elseif ($GitSource=='HITGitlab') {
|
||||
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
|
||||
|
||||
$tarfile = $tmppath . '/github.tar.gz';
|
||||
$githubfile = file_get_contents($url);
|
||||
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
|
||||
file_put_contents($tarfile, $githubfile);
|
||||
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
||||
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
||||
file_put_contents($tarfile, file_get_contents($url));
|
||||
$phar = new PharData($tarfile);
|
||||
$html = $phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
||||
unlink($tarfile);
|
||||
|
||||
$outPath = '';
|
||||
$tmp = scandir($tmppath);
|
||||
$name = $auth . '-' . $project;
|
||||
// 获取解压出的目录名
|
||||
$outPath = findIndexPath($tmppath);
|
||||
|
||||
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
||||
$name = $project . 'CODE';
|
||||
mkdir($tmppath . "/" . $name, 0777, 1);
|
||||
foreach ($tmp as $f) {
|
||||
if ( substr($f, 0, strlen($name)) == $name) {
|
||||
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
|
||||
$outPath = $tmppath . "/" . $name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rename($outPath, $tmppath . "/" . $name . '/api');
|
||||
$outPath = $tmppath . "/" . $name;
|
||||
//echo $outPath . "<br>";
|
||||
//error_log1($outPath);
|
||||
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
||||
|
||||
// put in config
|
||||
$coderoot = __DIR__;
|
||||
|
|
Loading…
Reference in New Issue