1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the composer-changelogs project. |
5
|
|
|
* |
6
|
|
|
* (c) Loïck Piera <[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 Pyrech\ComposerChangelogs\UrlGenerator; |
13
|
|
|
|
14
|
|
|
use Pyrech\ComposerChangelogs\Version; |
15
|
|
|
|
16
|
|
|
class BitbucketUrlGenerator extends AbstractUrlGenerator |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
16 |
|
protected function getDomain() |
22
|
|
|
{ |
23
|
16 |
|
return 'bitbucket.org'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
12 |
|
public function generateCompareUrl($sourceUrlFrom, Version $versionFrom, $sourceUrlTo, Version $versionTo) |
30
|
|
|
{ |
31
|
|
|
// Check if both urls come from the supported domain |
32
|
|
|
// It avoids problems when one url is from another domain or is local |
33
|
12 |
|
if (!$this->supports($sourceUrlFrom) || !$this->supports($sourceUrlTo)) { |
34
|
2 |
|
return false; |
35
|
|
|
} |
36
|
|
|
|
37
|
10 |
|
$sourceUrlFrom = $this->generateBaseUrl($sourceUrlFrom); |
38
|
10 |
|
$sourceUrlTo = $this->generateBaseUrl($sourceUrlTo); |
39
|
|
|
|
40
|
|
|
// Check if comparison across forks is needed |
41
|
10 |
|
if ($sourceUrlFrom !== $sourceUrlTo) { |
42
|
4 |
|
$repositoryFrom = $this->extractRepositoryInformation($sourceUrlFrom); |
43
|
4 |
|
$repositoryTo = $this->extractRepositoryInformation($sourceUrlTo); |
44
|
|
|
|
45
|
2 |
|
return sprintf( |
46
|
2 |
|
'%s/branches/compare/%s/%s:%s%%0D%s/%s:%s', |
47
|
2 |
|
$sourceUrlTo, |
48
|
2 |
|
$repositoryTo['user'], |
49
|
2 |
|
$repositoryTo['repository'], |
50
|
2 |
|
$this->getCompareVersion($versionTo), |
51
|
2 |
|
$repositoryFrom['user'], |
52
|
2 |
|
$repositoryFrom['repository'], |
53
|
2 |
|
$this->getCompareVersion($versionFrom) |
54
|
2 |
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
6 |
|
return sprintf( |
58
|
6 |
|
'%s/branches/compare/%s%%0D%s', |
59
|
6 |
|
$sourceUrlTo, |
60
|
6 |
|
$this->getCompareVersion($versionTo), |
61
|
6 |
|
$this->getCompareVersion($versionFrom) |
62
|
6 |
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
2 |
|
public function generateReleaseUrl($sourceUrl, Version $version) |
69
|
|
|
{ |
70
|
|
|
// Releases are not supported on Bitbucket :'( |
71
|
2 |
|
return false; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.