1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Conveyor package. |
5
|
|
|
* |
6
|
|
|
* (c) Jeroen Fiege <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Webcreate\Conveyor\Repository\Driver; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
15
|
|
|
use Webcreate\Conveyor\IO\IOInterface; |
16
|
|
|
use Webcreate\Conveyor\Repository\Version; |
17
|
|
|
use Webcreate\Vcs\Git; |
18
|
|
|
|
19
|
|
|
class GitDriver extends AbstractVcsDriver |
20
|
|
|
{ |
21
|
|
|
protected $dispatcher; |
22
|
|
|
|
23
|
1 |
|
public function __construct($url, IOInterface $io = null, EventDispatcherInterface $dispatcher = null) |
|
|
|
|
24
|
|
|
{ |
25
|
1 |
|
$this->url = $url; |
26
|
1 |
|
$this->io = $io; |
27
|
1 |
|
$this->dispatcher = $dispatcher; |
28
|
1 |
|
} |
29
|
|
|
|
30
|
|
|
protected function getClient($url) |
31
|
|
|
{ |
32
|
|
|
$client = new Git($url); |
33
|
|
|
$client->getAdapter()->setExecutable('git'); |
34
|
|
|
|
35
|
|
|
if (null !== $this->dispatcher) { |
36
|
|
|
$client->setDispatcher($this->dispatcher); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$client->setCwd($this->cacheDir . '/git/' . md5($url)); |
40
|
|
|
|
41
|
|
|
return $client; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* FIXME passing `null`, `null` failed on svn client, but looks like |
46
|
|
|
* it's needed by the git client. Fix the git client to accept |
47
|
|
|
* Reference's correctly! |
48
|
|
|
* |
49
|
|
|
* @param Version $oldVersion |
50
|
|
|
* @param Version $newVersion |
51
|
|
|
* @return \Webcreate\Vcs\Common\VcsFileInfo[] |
52
|
|
|
*/ |
53
|
|
|
public function diff(Version $oldVersion, Version $newVersion) |
54
|
|
|
{ |
55
|
|
|
$head = $this->getHead($oldVersion); |
56
|
|
|
$this->client->setHead($head); |
57
|
|
|
|
58
|
|
|
$result = $this->client->diff( |
59
|
|
|
null, null, |
60
|
|
|
$oldVersion->getBuild(), $newVersion->getBuild() |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
return $result; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.