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;
}