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
|
|
|
* Commits changes in a local working copy to the repository |
27
|
|
|
* |
28
|
|
|
* @author Johan Persson <[email protected]> |
29
|
|
|
* @package phing.tasks.ext.svn |
30
|
|
|
* @since 2.4.0 |
31
|
|
|
*/ |
32
|
|
|
class SvnCommitTask extends SvnBaseTask |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Commit message |
36
|
|
|
*/ |
37
|
|
|
private $message = ''; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Property name where we store the revision number of the just |
41
|
|
|
* committed version. |
42
|
|
|
*/ |
43
|
|
|
private $propertyName = "svn.committedrevision"; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Sets the commit message |
47
|
|
|
* |
48
|
|
|
* @param $message |
49
|
|
|
*/ |
50
|
|
|
public function setMessage($message) |
51
|
|
|
{ |
52
|
|
|
$this->message = $message; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Gets the commit message |
57
|
|
|
*/ |
58
|
|
|
public function getMessage() |
59
|
|
|
{ |
60
|
|
|
return $this->message; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Sets the name of the property to use for returned revision |
65
|
|
|
* |
66
|
|
|
* @param $propertyName |
67
|
|
|
*/ |
68
|
|
|
public function setPropertyName($propertyName) |
69
|
|
|
{ |
70
|
|
|
$this->propertyName = $propertyName; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Returns the name of the property to use for returned revision |
75
|
|
|
*/ |
76
|
|
|
public function getPropertyName() |
77
|
|
|
{ |
78
|
|
|
return $this->propertyName; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* The main entry point |
83
|
|
|
* |
84
|
|
|
* @throws BuildException |
85
|
|
|
*/ |
86
|
|
|
public function main() |
87
|
|
|
{ |
88
|
|
|
if (trim($this->message) === '') { |
89
|
|
|
throw new BuildException('SVN Commit message can not be empty.'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$this->setup('commit'); |
93
|
|
|
|
94
|
|
|
$this->log( |
95
|
|
|
"Committing SVN working copy at '" . $this->getWorkingCopy() . "' with message '" . $this->getMessage() . "'" |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
$output = $this->run([], ['message' => $this->getMessage()]); |
99
|
|
|
|
100
|
|
|
if (preg_match('/[\s]*Committed revision[\s]+([\d]+)/', $output, $matches)) { |
|
|
|
|
101
|
|
|
$this->project->setProperty($this->getPropertyName(), $matches[1]); |
102
|
|
|
} else { |
103
|
|
|
/** |
104
|
|
|
* If no new revision was committed set revision to "empty". Remember that |
105
|
|
|
* this is not necessarily an error. It could be that the specified working |
106
|
|
|
* copy is identical to the copy in the repository and in that case |
107
|
|
|
* there will be no update and no new revision number. |
108
|
|
|
*/ |
109
|
|
|
$this->project->setProperty($this->getPropertyName(), ''); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|