33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-24 13:47:35 +00:00
jedchecker/builds/phingext/GitVersionTask.php

55 lines
1.2 KiB
PHP
Raw Normal View History

2012-05-21 08:33:11 +00:00
<?php
require_once 'phing/Task.php';
require_once 'phing/tasks/ext/svn/SvnBaseTask.php';
/**
* Git latest tree version to Phing property
* @package akeebabuilder
* @copyright Copyright (c)2009-2010 Nicholas K. Dionysopoulos
* @license GNU GPL version 3 or, at your option, any later version
* @author nicholas
*/
class GitVersionTask extends SvnBaseTask
{
private $propertyName = "git.version";
/**
* Sets the name of the property to use
*/
function setPropertyName($propertyName)
{
$this->propertyName = $propertyName;
}
/**
* Returns the name of the property to use
*/
function getPropertyName()
{
return $this->propertyName;
}
/**
* Sets the path to the working copy
*/
function setWorkingCopy($wc)
{
$this->workingCopy = $wc;
}
/**
* The main entry point
*
* @throws BuildException
*/
function main()
{
$this->setup('info');
exec('git log -n 1 --no-decorate --pretty=format:"%h" '.escapeshellarg(realpath($this->workingCopy)), $out);
$version = $out[0];
$this->project->setProperty($this->getPropertyName(), $version);
}
}