feat: VersionGit에 'hash' 추가.(WIP)
This commit is contained in:
@@ -36,6 +36,7 @@ d_pic/uploaded_image
|
||||
d_setting/*.php
|
||||
*/d_setting/*.php
|
||||
*/d_setting/templates/*.php
|
||||
!*.orig.php
|
||||
|
||||
*/data/file_cache
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class VersionGit extends VersionGitDynamic {
|
||||
}
|
||||
@@ -3,7 +3,8 @@ namespace sammo;
|
||||
|
||||
class VersionGit{
|
||||
public static $version = '_tK_verionGit_';
|
||||
public static $hash = '_tK_hash_';
|
||||
|
||||
private function __construct(){}
|
||||
}
|
||||
//{"version":"_tK_verionGit_"}
|
||||
//{"version":"_tK_verionGit_","hash":"_tK_hash_"}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
class VersionGitDynamic
|
||||
{
|
||||
public static $version = '_tK_verionGit_';
|
||||
|
||||
static function getVersion()
|
||||
{
|
||||
$command = 'git describe --long --tags';
|
||||
exec($command, $output);
|
||||
if (is_array($output)) {
|
||||
$output = join('', $output);
|
||||
}
|
||||
return trim($output);
|
||||
}
|
||||
|
||||
static function getHash()
|
||||
{
|
||||
$command = 'git rev-parse HEAD';
|
||||
exec($command, $output);
|
||||
if (is_array($output)) {
|
||||
$output = join('', $output);
|
||||
}
|
||||
return trim($output);
|
||||
}
|
||||
|
||||
static function __get($name){
|
||||
if($name === 'version'){
|
||||
return static::getVersion();
|
||||
}
|
||||
if($name === 'hash'){
|
||||
return static::getHash();
|
||||
}
|
||||
trigger_error("Undefined property $name");
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
//{"version":"_tK_verionGit_"}
|
||||
+32
-10
@@ -18,6 +18,16 @@ function getVersion($target = null)
|
||||
return trim($output);
|
||||
}
|
||||
|
||||
function getHash($target = 'HEAD')
|
||||
{
|
||||
$command = sprintf('git rev-parse %s', escapeshellarg($target));
|
||||
exec($command, $output);
|
||||
if (is_array($output)) {
|
||||
$output = join('', $output);
|
||||
}
|
||||
return trim($output);
|
||||
}
|
||||
|
||||
$session = Session::requireLogin(null)->setReadOnly();
|
||||
|
||||
$request = $_POST + $_GET;
|
||||
@@ -142,15 +152,25 @@ if ($server == $baseServerName) {
|
||||
]);
|
||||
}
|
||||
|
||||
$version = getVersion();
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if (
|
||||
hash_file("sha256", __DIR__ . '/' . $server . '/d_setting/VersionGit.dynamic.orig.php') ==
|
||||
hash_file("sha256", __DIR__ . '/' . $server . '/d_setting/VersionGit.php')) {
|
||||
$result = true;
|
||||
}
|
||||
else{
|
||||
$version = getVersion();
|
||||
$hash = getHash();
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version,
|
||||
'hash' => $hash
|
||||
],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
if (ServConfig::$imageRequestKey) {
|
||||
try {
|
||||
@@ -218,11 +238,13 @@ $zip->close();
|
||||
@unlink($tmpFile);
|
||||
|
||||
$version = getVersion($target);
|
||||
$gitHash = getHash($target);
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.orig.php',
|
||||
__DIR__ . '/' . $server . '/d_setting/VersionGit.php',
|
||||
[
|
||||
'verionGit' => $version
|
||||
'verionGit' => $version,
|
||||
'hash' => $gitHash
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user