Skip to content

Instantly share code, notes, and snippets.

@breadthe
Last active December 28, 2022 10:31
Show Gist options
  • Select an option

  • Save breadthe/ce6a815b295c485b4bd91c08a79e1bf2 to your computer and use it in GitHub Desktop.

Select an option

Save breadthe/ce6a815b295c485b4bd91c08a79e1bf2 to your computer and use it in GitHub Desktop.

Revisions

  1. breadthe revised this gist Nov 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion version.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    // Based on this tweet by @Xewl https://twitter.com/Xewl/status/1459219464369627144

    $tag = exec('git describe --tags --abbrev=0');
    if (empty($tag) {
    if (empty($tag)) {
    $tag = '-.-.-';
    }

  2. breadthe revised this gist Nov 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion version.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    // Based on this tweet by @Xewl https://twitter.com/Xewl/status/1459219464369627144

    $tag = exec('git describe --tags --abbrev=0');
    if ($empty($tag) {
    if (empty($tag) {
    $tag = '-.-.-';
    }

  3. breadthe created this gist Nov 14, 2021.
    13 changes: 13 additions & 0 deletions version.blade.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    // resources/views/app/version.blade.php

    <div>
    <span>{{ config('version.string') }}</span>
    <span>&mdsh;</span>
    <span>{{ config('app.env') }}</span>
    <span>&mdash;</span>
    <span>{{ 'Laravel ' . app()->version() }}</span>
    <span>&mdash;</span>
    <span>{{ app()->getLocale() }}</span>
    <span>&mdash;</span>
    <span>{{ 'PHP ' . PHP_VERSION }}</span>
    </div>
    18 changes: 18 additions & 0 deletions version.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    <?php
    // config/version.php
    // Based on this tweet by @Xewl https://twitter.com/Xewl/status/1459219464369627144

    $tag = exec('git describe --tags --abbrev=0');
    if ($empty($tag) {
    $tag = '-.-.-';
    }

    $hash = trim(exec('git log --pretty="%h" -n1 HEAD'));
    $date = Carbon\Carbon::parse(trim(exec('git log -n1 --pretty=%ci HEAD')));

    return [
    'tag' => $tag,
    'date' => $date,
    'hash' => $hash,
    'string' => sprintf('%s-%s (%s)', $tag, $hash, $date->format('d/m/y H:i'));
    ];