1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the LGPL. For more information please see |
18
|
|
|
* <http://phing.info>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Phing\Tasks\Ext; |
22
|
|
|
|
23
|
|
|
use Phing\Exception\BuildException; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Stores the output of a log command on a workingcopy or repositoryurl in a property. |
27
|
|
|
* This stems from the SvnLastRevisionTask. |
28
|
|
|
* |
29
|
|
|
* @author Anton Stöckl <[email protected]> |
30
|
|
|
* @author Michiel Rook <[email protected]> (SvnLastRevisionTask) |
31
|
|
|
* @package phing.tasks.ext.svn |
32
|
|
|
* @see VersionControl_SVN |
33
|
|
|
* @since 2.1.0 |
34
|
|
|
*/ |
35
|
|
|
class SvnLogTask extends SvnBaseTask |
36
|
|
|
{ |
37
|
|
|
private $propertyName = "svn.log"; |
38
|
|
|
private $limit = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Sets the name of the property to use |
42
|
|
|
* |
43
|
|
|
* @param $propertyName |
44
|
|
|
*/ |
45
|
|
|
public function setPropertyName($propertyName) |
46
|
|
|
{ |
47
|
|
|
$this->propertyName = $propertyName; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns the name of the property to use |
52
|
|
|
*/ |
53
|
|
|
public function getPropertyName() |
54
|
|
|
{ |
55
|
|
|
return $this->propertyName; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Sets the max num of log entries to get from svn |
60
|
|
|
* |
61
|
|
|
* @param $limit |
62
|
|
|
*/ |
63
|
|
|
public function setLimit($limit) |
64
|
|
|
{ |
65
|
|
|
$this->limit = (int) $limit; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* The main entry point |
70
|
|
|
* |
71
|
|
|
* @throws BuildException |
72
|
|
|
*/ |
73
|
|
|
public function main() |
74
|
|
|
{ |
75
|
|
|
$this->setup('log'); |
76
|
|
|
|
77
|
|
|
$switches = []; |
78
|
|
|
if ($this->limit > 0) { |
79
|
|
|
$switches['limit'] = $this->limit; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$output = $this->run([], $switches); |
83
|
|
|
$result = null; |
84
|
|
|
|
85
|
|
|
if ($this->oldVersion) { |
86
|
|
|
foreach ($output as $line) { |
87
|
|
|
$result .= (!empty($result)) ? "\n" : ''; |
88
|
|
|
$result .= "{$line['REVISION']} | {$line['AUTHOR']} | {$line['DATE']} | {$line['MSG']}"; |
89
|
|
|
} |
90
|
|
|
} else { |
91
|
|
|
foreach ($output['logentry'] as $line) { |
92
|
|
|
$result .= (!empty($result)) ? "\n" : ''; |
93
|
|
|
$result .= "{$line['revision']} | {$line['author']} | {$line['date']} | {$line['msg']}"; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
if (!empty($result)) { |
98
|
|
|
$this->project->setProperty($this->getPropertyName(), $result); |
99
|
|
|
} else { |
100
|
|
|
throw new BuildException("Failed to parse the output of 'svn log'."); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|