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

CPS-IT / frontend-asset-handler / 15251341592

26 May 2025 10:12AM UTC coverage: 99.233%. Remained the same
15251341592

Pull #659

github

web-flow
Merge c6e7b1587 into 8b95d2cff
Pull Request #659: [TASK] Update phpunit/phpunit to v12

2459 of 2478 relevant lines covered (99.23%)

15.09 hits per line

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

95.65
/src/Helper/VcsHelper.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "cpsit/frontend-asset-handler".
7
 *
8
 * Copyright (C) 2022 Elias Häußler <e.haeussler@familie-redlich.de>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace CPSIT\FrontendAssetHandler\Helper;
25

26
use OndraM\CiDetector\CiDetector;
27
use Symfony\Component\Process;
28

29
use function trim;
30

31
/**
32
 * VcsHelper.
33
 *
34
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
35
 * @license GPL-3.0-or-later
36
 *
37
 * @api
38
 */
39
final class VcsHelper
40
{
41
    public static function getCurrentBranch(): ?string
23✔
42
    {
43
        if (null !== ($branch = self::getCurrentBranchFromEnvironment())) {
23✔
44
            return $branch;
1✔
45
        }
46
        if (null !== ($branch = self::getCurrentBranchFromCi())) {
22✔
47
            return $branch;
19✔
48
        }
49

50
        $process = new Process\Process(['git', 'symbolic-ref', '--short', 'HEAD']);
22✔
51
        $process->run();
22✔
52

53
        if ($process->isSuccessful()) {
22✔
54
            return trim($process->getIncrementalOutput());
1✔
55
        }
56

57
        return null;
21✔
58
    }
59

60
    private static function getCurrentBranchFromEnvironment(): ?string
23✔
61
    {
62
        $branch = getenv('FRONTEND_ASSETS_BRANCH');
23✔
63

64
        if (false !== $branch) {
23✔
65
            return $branch;
1✔
66
        }
67

68
        return null;
22✔
69
    }
70

71
    private static function getCurrentBranchFromCi(): ?string
22✔
72
    {
73
        $ciDetector = new CiDetector();
22✔
74

75
        if (!$ciDetector->isCiDetected()) {
22✔
76
            return null;
22✔
77
        }
78

79
        $branch = $ciDetector->detect()->getBranch();
19✔
80

81
        if ('' === trim($branch)) {
19✔
82
            return null;
×
83
        }
84

85
        return $branch;
19✔
86
    }
87
}
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

© 2026 Coveralls, Inc