Permalink
Browse files

Do not perform string replacement for @package_version@ anymore. Impr…

…oved version information when used from a Git checkout.
  • Loading branch information...
1 parent 8151e0e commit febf71de8718dc2741c2fd0c53831855d56e2f94 @sebastianbergmann committed Oct 5, 2012
View
@@ -51,7 +51,6 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
- * @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phploc/tree
* @since Class available since Release 1.0.0
*/
View
@@ -62,7 +62,8 @@ function($class) {
'phploc_textui_command' => '/TextUI/Command.php',
'phploc_textui_resultprinter_csv' => '/TextUI/ResultPrinter/CSV.php',
'phploc_textui_resultprinter_text' => '/TextUI/ResultPrinter/Text.php',
- 'phploc_textui_resultprinter_xml' => '/TextUI/ResultPrinter/XML.php'
+ 'phploc_textui_resultprinter_xml' => '/TextUI/ResultPrinter/XML.php',
+ 'phploc_version' => '/Version.php'
);
}
@@ -47,7 +47,6 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
- * @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phploc/tree
* @since Class available since Release 1.0.0
*/
@@ -261,7 +260,9 @@ protected function showHelp()
*/
protected function printVersionString()
{
- print "phploc @package_version@ by Sebastian Bergmann.\n\n";
+ printf(
+ "phploc %s by Sebastian Bergmann.\n\n", PHPLOC_Version::id()
+ );
}
/**
@@ -47,7 +47,6 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
- * @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phploc/tree
* @since Class available since Release 1.6.0
*/
@@ -47,7 +47,6 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
- * @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phploc/tree
* @since Class available since Release 1.0.0
*/
@@ -47,7 +47,6 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
- * @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phploc/tree
* @since Class available since Release 1.1.0
*/
View
@@ -0,0 +1,84 @@
+<?php
+/**
+ * phploc
+ *
+ * Copyright (c) 2009-2012, Sebastian Bergmann <sb@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package phploc
+ * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
+ * @since File available since Release 1.7.0
+ */
+
+/**
+ * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
+ * @link http://github.com/sebastianbergmann/phploc/tree
+ * @since Class available since Release 1.7.0
+ */
+class PHPLOC_Version
+{
+ const VERSION = '1.7';
+ protected static $version;
+
+ /**
+ * @return string
+ */
+ public static function id()
+ {
+ if (self::$version === NULL) {
+ self::$version = self::VERSION;
+
+ if (is_dir(dirname(__DIR__) . '/.git')) {
+ $dir = getcwd();
+ chdir(__DIR__);
+ $version = exec('git describe --tags');
+ chdir($dir);
+
+ if ($version) {
+ if (count(explode('.', self::VERSION)) == 3) {
+ self::$version = $version;
+ } else {
+ $version = explode('-', $version);
+
+ self::$version = self::VERSION . '-' . $version[2];
+ }
+ }
+ }
+ }
+
+ return self::$version;
+ }
+}
View
@@ -52,7 +52,6 @@
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2012 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
- * @version Release: @package_version@
* @link http://github.com/sebastianbergmann/phploc/
* @since Class available since Release 1.3.0
*/
View
@@ -17,7 +17,7 @@
<email>sb@sebastian-bergmann.de</email>
<active>yes</active>
</lead>
- <date>2011-12-DD</date>
+ <date>2012-MM-DD</date>
<version>
<release>1.7.0</release>
<api>1.7.0</api>
@@ -33,36 +33,22 @@
<dir name="PHPLOC">
<dir name="TextUI">
<dir name="ResultPrinter">
- <file baseinstalldir="/" name="CSV.php" role="php">
- <tasks:replace from="@package_version@" to="version" type="package-info" />
- </file>
- <file baseinstalldir="/" name="Text.php" role="php">
- <tasks:replace from="@package_version@" to="version" type="package-info" />
- </file>
- <file baseinstalldir="/" name="XML.php" role="php">
- <tasks:replace from="@package_version@" to="version" type="package-info" />
- </file>
+ <file baseinstalldir="/" name="CSV.php" role="php" />
+ <file baseinstalldir="/" name="Text.php" role="php" />
+ <file baseinstalldir="/" name="XML.php" role="php" />
</dir>
- <file baseinstalldir="/" name="Command.php" role="php">
- <tasks:replace from="@package_version@" to="version" type="package-info" />
- </file>
+ <file baseinstalldir="/" name="Command.php" role="php" />
</dir>
- <file baseinstalldir="/" name="Analyser.php" role="php">
- <tasks:replace from="@package_version@" to="version" type="package-info" />
- </file>
- <file baseinstalldir="/" name="Autoload.php" role="php">
- <tasks:replace from="@package_version@" to="version" type="package-info" />
- </file>
+ <file baseinstalldir="/" name="Analyser.php" role="php" />
+ <file baseinstalldir="/" name="Autoload.php" role="php" />
</dir>
<file baseinstalldir="/" name="phploc.php" role="script">
<tasks:replace from="/usr/bin/env php" to="php_bin" type="pear-config"/>
<tasks:replace from="@php_bin@" to="php_bin" type="pear-config" />
- <tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
<file baseinstalldir="/" name="phploc.bat" role="script">
<tasks:replace from="@php_bin@" to="php_bin" type="pear-config" />
<tasks:replace from="@bin_dir@" to="bin_dir" type="pear-config" />
- <tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
</dir>
</contents>

0 comments on commit febf71d

Please sign in to comment.