minor fixes for changelog and getAppVersion

This commit is contained in:
ArabCoders
2025-02-04 18:11:21 +03:00
parent 9127a89a13
commit 1252e71e11
3 changed files with 19 additions and 16 deletions

View File

@@ -17,7 +17,7 @@
<span class="icon-text">
<span class="icon"><i class="fas fa-code-branch"></i></span>
<span>
{{ log.tag }} <span class="subtitle" v-if="log.tag === api_version">Installed</span>
{{ log.tag }} <span class="subtitle has-text-success" v-if="log.tag === api_version">Installed</span>
</span>
</span>
</h1>
@@ -26,9 +26,12 @@
<li v-for="commit in log.commits" :key="commit.sha">
<strong>{{ ucFirst(commit.message).replace(/\.$/, "") }}.</strong> -
<small>
<span class="has-tooltip" v-tooltip="`Date: ${commit.date}`">
{{ moment(commit.date).fromNow() }}
</span></small>
<NuxtLink :to="`https://github.com/arabcoders/watchstate/commit/${commit.sha}`" target="_blank">
<span class="has-tooltip" v-tooltip="`SHA: ${commit.sha} - Date: ${commit.date}`">
{{ moment(commit.date).fromNow() }}
</span>
</NuxtLink>
</small>
</li>
</ul>
<hr v-if="index < logs.length - 1">
@@ -39,16 +42,17 @@
<script setup>
import { notification } from '~/utils/index'
import moment from 'moment'
import { NuxtLink } from '#components';
useHead({ title: 'Change log' })
const REPO_URL = "https://arabcoders.github.io/watchstate/CHANGELOG-{branch}.json?version={version}";
const logs = ref([]);
const api_version = ref('dev');
const api_version = ref('master');
const branch = computed(() => {
const branch = String(api_version.value).split('-')[0] ?? 'dev';
return ['master', 'dev'].includes(branch) ? branch : 'dev';
const branch = String(api_version.value).split('-')[0] ?? 'master';
return ['master', 'dev'].includes(branch) ? branch : 'master';
});
const loadContent = async () => {

View File

@@ -283,7 +283,6 @@ final class Index
$sql[] = 'WHERE ' . implode(' AND ', $where);
}
syslog(LOG_DEBUG, json_encode($data->getAll()));
$stmt = $db->prepare('SELECT COUNT(*) ' . implode(' ', array_map('trim', $sql)));
$stmt->execute($params);
$total = $stmt->fetchColumn();

View File

@@ -788,24 +788,24 @@ if (!function_exists('getAppVersion')) {
if ('$(version_via_ci)' === $version) {
$gitDir = ROOT_PATH . DIRECTORY_SEPARATOR . '.git' . DIRECTORY_SEPARATOR;
if (is_dir($gitDir) && is_executable('git')) {
if (is_dir($gitDir)) {
try {
// Get the current branch name.
$cmdBranch = 'git --git-dir=%1$s rev-parse --abbrev-ref HEAD';
$procBranch = Process::fromShellCommandline(sprintf($cmdBranch, escapeshellarg($gitDir)));
$cmdBranch = 'git --git-dir={cwd} rev-parse --abbrev-ref HEAD';
$procBranch = Process::fromShellCommandline(r($cmdBranch, ['cwd' => escapeshellarg($gitDir)]));
$procBranch->run();
$branch = $procBranch->isSuccessful() ? trim($procBranch->getOutput()) : 'unknown';
// Get the short commit hash.
$cmdCommit = 'git --git-dir=%1$s rev-parse --short HEAD';
$procCommit = Process::fromShellCommandline(sprintf($cmdCommit, escapeshellarg($gitDir)));
$cmdCommit = 'git --git-dir={cwd} rev-parse --short HEAD';
$procCommit = Process::fromShellCommandline(r($cmdCommit, ['cwd' => escapeshellarg($gitDir)]));
$procCommit->run();
$commit = $procCommit->isSuccessful() ? trim($procCommit->getOutput()) : 'unknown';
// Get the commit date (from HEAD) in YYYYMMDD format.
// This uses "git show" with a custom date format.
$cmdDate = 'git --git-dir=%1$s show -s --format=%cd --date=format:%Y%m%d HEAD';
$procDate = Process::fromShellCommandline(sprintf($cmdDate, escapeshellarg($gitDir)));
$cmdDate = 'git --git-dir={cwd} show -s --format=%cd --date=format:%Y%m%d HEAD';
$procDate = Process::fromShellCommandline(r($cmdDate, ['cwd' => escapeshellarg($gitDir)]));
$procDate->run();
$commitDate = $procDate->isSuccessful() ? trim($procDate->getOutput()) : date('Ymd');
@@ -816,7 +816,7 @@ if (!function_exists('getAppVersion')) {
'commit' => $commit,
]);
} catch (Throwable) {
return $version;
return 'dev-master';
}
}