feat: Add function to retrieve commit hash

- Added a new function `getCommitHash` to fetch the latest commit hash using Git log command and cache it for 3 days.
This commit is contained in:
Rico van Zelst
2024-06-18 12:44:24 +02:00
parent 68dd3dd2f8
commit 5038a18397
2 changed files with 13 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
use App\Models\ChampionImage;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;
use Illuminate\Support\Facades\Cache;
function getRoleIcon($roleName): string
{
@@ -83,3 +84,13 @@ function getChampionImage($full_id, $type): string
return $championImage->url;
}
function getCommitHash(): string
{
/** @var string $commit */
$commit = Cache::remember('commit_hash', 60 * 72, function () {
return trim(exec('git log --pretty="%h" -n1 HEAD'));
});
return $commit;
}

View File

@@ -53,5 +53,7 @@
href="/" class="hover:underline">Heimerdinger.LoL</a> Made with <a
aria-label="Find out more about the creator of Heimerdinger.lol" href="https://rico.sh"><x-iconsax-bul-heart-circle
class="relative self-center inline-block w-5 text-red-400"/></a></span>
<span> <p class="mt-3 font-mono text-sm text-gray-200 opacity-75">Version: {{ getCommitHash() }}</p> </span>
</div>
</footer>