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

68publishers / tracy-git-version / 5982422976

26 Aug 2023 02:55AM UTC coverage: 90.041% (-2.2%) from 92.276%
5982422976

Pull #4

github

web-flow
Merge 0c60a3907 into fa82db0dd
Pull Request #4: Feature/git executable

465 of 465 new or added lines in 32 files covered. (100.0%)

434 of 482 relevant lines covered (90.04%)

0.9 hits per line

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

80.0
/src/Bridge/Tracy/GitVersionPanel.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\TracyGitVersion\Bridge\Tracy;
6

7
use SixtyEightPublishers\TracyGitVersion\Bridge\Tracy\Block\BlockInterface;
8
use SixtyEightPublishers\TracyGitVersion\Bridge\Tracy\Block\CurrentStateBlock;
9
use SixtyEightPublishers\TracyGitVersion\Repository\GitCommandHandlerInterface;
10
use SixtyEightPublishers\TracyGitVersion\Repository\GitRepositoryInterface;
11
use SixtyEightPublishers\TracyGitVersion\Repository\LocalGitRepository;
12
use SixtyEightPublishers\TracyGitVersion\Repository\RuntimeCachedGitRepository;
13
use Throwable;
14
use Tracy\IBarPanel;
15

16
final class GitVersionPanel implements IBarPanel
17
{
18
    private GitRepositoryInterface $gitRepository;
19

20
    /** @var array<BlockInterface> */
21
    private array $blocks;
22

23
    /**
24
     * @param array<BlockInterface> $blocks
25
     */
26
    public function __construct(GitRepositoryInterface $gitRepository, array $blocks)
27
    {
28
        $this->gitRepository = $gitRepository;
1✔
29
        $this->blocks = (static fn (BlockInterface ...$blocks): array => $blocks)(...$blocks);
1✔
30
    }
1✔
31

32
    /**
33
     * @param array<class-string, GitCommandHandlerInterface> $handlers
34
     */
35
    public static function createDefault(?string $workingDirectory = null, string $directoryName = '.git', array $handlers = []): self
36
    {
37
        $repository = new RuntimeCachedGitRepository(LocalGitRepository::createDefault($workingDirectory, $directoryName));
1✔
38

39
        foreach ($handlers as $command => $handler) {
1✔
40
            $repository->addHandler($command, $handler);
×
41
        }
42

43
        return new self($repository, [
1✔
44
            new CurrentStateBlock(),
1✔
45
        ]);
46
    }
47

48
    public function addBlock(BlockInterface $block): self
49
    {
50
        $this->blocks[] = $block;
×
51

52
        return $this;
×
53
    }
54

55
    /**
56
     * @throws Throwable
57
     */
58
    public function getTab(): string
59
    {
60
        return Helpers::renderTemplate(__DIR__ . '/templates/GitVersionPanel.tab.phtml', [
1✔
61
            'gitRepository' => $this->gitRepository,
1✔
62
        ]);
63
    }
64

65
    /**
66
     * @throws Throwable
67
     */
68
    public function getPanel(): string
69
    {
70
        return Helpers::renderTemplate(__DIR__ . '/templates/GitVersionPanel.panel.phtml', [
1✔
71
            'gitRepository' => $this->gitRepository,
1✔
72
            'blocks' => $this->blocks,
1✔
73
        ]);
74
    }
75
}
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