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

violinist-dev / composer-changelog-fetcher / 10504684586

22 Aug 2024 08:35AM UTC coverage: 88.971%. Remained the same
10504684586

push

github

web-flow
Change username / pass logic to work with more types of tokens (#14)

0 of 1 new or added line in 1 file covered. (0.0%)

121 of 136 relevant lines covered (88.97%)

1.76 hits per line

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

65.38
/src/DependencyRepoRetriever.php
1
<?php
2

3
namespace Violinist\ChangelogFetcher;
4

5
use Violinist\ProcessFactory\ProcessFactoryInterface;
6

7
use function peterpostmann\uri\parse_uri;
8

9
class DependencyRepoRetriever
10
{
11
    protected $processFactory;
12

13
    protected $authToken;
14

15
    public function __construct(ProcessFactoryInterface $processFactory)
16
    {
17
        $this->processFactory = $processFactory;
3✔
18
    }
19

20
    public function setAuthToken($token)
21
    {
22
        $this->authToken = $token;
×
23
    }
24

25
    public function retrieveDependencyRepo($data)
26
    {
27
        // First find the repo source.
28
        if (!isset($data->source) || $data->source->type != 'git') {
3✔
29
            throw new \Exception(sprintf('Unknown source or non-git source found for %s. Aborting.', $data->name));
1✔
30
        }
31
        if (empty($data->name)) {
2✔
32
            throw new \Exception('No package name found');
×
33
        }
34
        // We could have this cached in the md5 of the package name.
35
        $clone_path = '/tmp/' . md5($data->name);
2✔
36
        $repo_path = $data->source->url;
2✔
37
        $repo_parsed = parse_uri($repo_path);
2✔
38
        if (!empty($repo_parsed)) {
2✔
39
            switch ($repo_parsed['_protocol']) {
2✔
40
                case 'git@github.com':
2✔
41
                    $repo_path = sprintf(
×
NEW
42
                        'https://x-access-token:%s@github.com/%s',
×
43
                        $this->authToken,
×
44
                        $repo_parsed['path']
×
45
                    );
×
46
                    break;
×
47
            }
48
        }
49
        if (!file_exists($clone_path)) {
2✔
50
            $command = ['git', 'clone', $repo_path, $clone_path];
2✔
51
        } else {
52
            $command = ['git', '-C', $clone_path, 'pull'];
×
53
        }
54
        $process = $this->processFactory->getProcess($command);
2✔
55
        $process->run();
2✔
56
        if ($process->getExitCode()) {
2✔
57
            throw new \Exception('Wrong exit code from retrieving git repo: ' . $process->getExitCode());
1✔
58
        }
59
        return $clone_path;
1✔
60
    }
61
}
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