• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JBZoo / Composer-Graph / 5399088069

pending completion
5399088069

push

github

web-flow
New code style and PHP 8.1+ (#14)

86 of 86 new or added lines in 5 files covered. (100.0%)

276 of 310 relevant lines covered (89.03%)

76.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Helper.php
1
<?php
2

3
/**
4
 * JBZoo Toolbox - Composer-Graph.
5
 *
6
 * This file is part of the JBZoo Toolbox project.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT
11
 * @copyright  Copyright (C) JBZoo.com, All rights reserved.
12
 * @see        https://github.com/JBZoo/Composer-Graph
13
 */
14

15
declare(strict_types=1);
16

17
namespace JBZoo\ComposerGraph;
18

19
use JBZoo\Utils\Cli;
20

21
class Helper
22
{
23
    public const HASH_LENGTH = 7;
24

25
    public static function getGitVersion(): ?string
26
    {
27
        try {
28
            $tag = \trim(Cli::exec('git describe --abbrev=0 --tags'));
×
29
            if ($tag !== '') {
×
30
                return $tag;
×
31
            }
32
        } catch (\Exception) {
×
33
            try {
34
                $branch = \trim(Cli::exec('git rev-parse --abbrev-ref HEAD'));
×
35
                if ($branch !== '') {
×
36
                    return "dev-{$branch}";
×
37
                }
38
            } catch (\Exception) {
×
39
                try {
40
                    $commit = \trim(Cli::exec('git rev-parse HEAD'));
×
41
                    if ($commit !== '') {
×
42
                        return \substr($commit, 0, self::HASH_LENGTH);
×
43
                    }
44
                } catch (\Exception) {
×
45
                    return null;
×
46
                }
47
            }
48
        }
49

50
        return null;
×
51
    }
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc