Skip to content

Commit

Permalink
Allow to get scm info from files; update copyright year; remove php c…
Browse files Browse the repository at this point in the history
…losing tag
  • Loading branch information
gggeek committed Mar 31, 2017
1 parent 04e3cb5 commit e7260dc
Show file tree
Hide file tree
Showing 85 changed files with 160 additions and 163 deletions.
3 changes: 0 additions & 3 deletions autoloads/eztemplateautoload.php
Expand Up @@ -4,6 +4,3 @@
$eZTemplateOperatorArray[] = array( 'script' => 'extension/ggsysinfo/autoloads/ggsysinfotemplateoperators.php',
'class' => 'ggSysinfoTemplateOperators',
'operator_names' => array_keys( ggSysinfoTemplateOperators::$operators ) );


?>
2 changes: 0 additions & 2 deletions autoloads/ggsysinfotemplateoperators.php
Expand Up @@ -89,5 +89,3 @@ public function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace
}

}

?>
4 changes: 1 addition & 3 deletions bin/php/report.php
Expand Up @@ -8,7 +8,7 @@
* also this script uses a custom autoloader for php classes
*
* @author G. Giunta
* @copyright (C) G. Giunta 2012-2016
* @copyright (C) G. Giunta 2012-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*
* @todo add options to let users to select which tests to run when running status report (ALL by default)
Expand Down Expand Up @@ -196,5 +196,3 @@ public static function autoloadCallback( $php, $label )
}
}
}

?>
4 changes: 1 addition & 3 deletions classes/contentstatsgatherer.php
Expand Up @@ -2,7 +2,7 @@
/**
*
* @author G. Giunta
* @copyright (C) G. Giunta 2012-2016
* @copyright (C) G. Giunta 2012-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*
* @todo add more classes of content that have no stats in main admin interface
Expand Down Expand Up @@ -85,5 +85,3 @@ static function gather()
return $contentList;
}
}

?>
3 changes: 1 addition & 2 deletions classes/dbchecker.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2012-2016
* @copyright (C) G. Giunta 2012-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down Expand Up @@ -47,4 +47,3 @@ static function checkDatabase()


}
?>
2 changes: 0 additions & 2 deletions classes/ezcGraphGdDriver2.php
Expand Up @@ -13,5 +13,3 @@ public function render( $file )
parent::render( $file );
}
}

?>
2 changes: 1 addition & 1 deletion classes/ezinactiveextensionloader.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
3 changes: 1 addition & 2 deletions classes/ezlogsgrapher.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2008-2016
* @copyright (C) G. Giunta 2008-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down Expand Up @@ -184,4 +184,3 @@ static function lastError()
return self::$lastError;
}
}
?>
4 changes: 1 addition & 3 deletions classes/ezmodulelister.php
Expand Up @@ -4,7 +4,7 @@
* Copied here from ezwebservicesapi and renamed to avoid clashes
*
* @author G. Giunta
* @copyright (C) G. Giunta 2010-2016
* @copyright (C) G. Giunta 2010-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down Expand Up @@ -39,5 +39,3 @@ static function getModuleList()
}*/
}

?>
2 changes: 1 addition & 1 deletion classes/ezsysinfoclustermanager.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/ezsysinfomodule.php
Expand Up @@ -3,7 +3,7 @@
* Class used to help managing in a single place all module/view info
*
* @author G. Giunta
* @copyright (C) G. Giunta 2010-2016
* @copyright (C) G. Giunta 2010-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
93 changes: 75 additions & 18 deletions classes/ezsysinfoscmchecker.php
Expand Up @@ -20,7 +20,6 @@ public function getDescription()
}

/**
* @todo add check that 'git' is executable
* @return bool
*/
public static function hasScmInfo()
Expand All @@ -34,7 +33,10 @@ public static function hasScmInfo()
*/
public static function getScmInfo()
{
$dirs = self::getScmDir();
$ini = eZINI::instance( 'sysinfo.ini' );
$type = $ini->variable('SCMSettings', 'RepoType');

$dirs = self::getScmDir($type);
if (!$dirs) {
return array();
}
Expand All @@ -53,37 +55,92 @@ public static function getScmInfo()
continue;
}

$revisionInfo = array();
exec( "cd $dir && git log -1", $revisionInfo, $retcode );
switch( $type )
{
case 'git':
$out[$name] = static::getRevisionInfoFromGit($dir);
break;
case 'file':
$out[$name] = static::getRevisionInfoFromFiles($dir);
break;
default:
eZDebug::writeError( "Unsupported scm type '$type'", __METHOD__ );
}
}

return $out;
}

/**
* @param string $dir
* @return array
* @todo add check that 'git' is executable
*/
protected static function getRevisionInfoFromGit( $dir )
{
$revisionInfo = array();
exec( "cd $dir && git log -1", $revisionInfo, $retcode );

$statusInfo = array();
exec( "cd $dir && git status", $statusInfo, $retcode );
$statusInfo = array();
exec( "cd $dir && git status", $statusInfo, $retcode );

$tagInfo = array();
exec( "cd $dir && git describe", $tagInfo, $retcode );
$tagInfo = array();
exec( "cd $dir && git describe", $tagInfo, $retcode );

$out[$name] = array(
'revision_info' => $revisionInfo,
'status_info' => $statusInfo,
'tag_info' => $tagInfo
);
return array(
'revision_info' => $revisionInfo,
'status_info' => $statusInfo,
'tag_info' => $tagInfo
);
}

protected static function getRevisionInfoFromFiles( $dir )
{
$revisionInfo = array();
if ( is_file( "$dir/revision.txt" ) )
{
$revisionInfo = file( "$dir/revision.txt", FILE_IGNORE_NEW_LINES );
}

return $out;
$statusInfo = array();
if ( is_file( "$dir/status.txt" ) )
{
$revisionInfo = file( "$dir/status.txt", FILE_IGNORE_NEW_LINES );
}

$tagInfo = array();
if ( is_file( "$dir/tag.txt" ) )
{
$revisionInfo = file( "$dir/tag.txt", FILE_IGNORE_NEW_LINES );
}

return array(
'revision_info' => $revisionInfo,
'status_info' => $statusInfo,
'tag_info' => $tagInfo
);
}

/**
* @return false|array|string
*/
protected static function getScmDir()
protected static function getScmDir($type)
{
$ini = eZINI::instance( 'sysinfo.ini' );
$dir = $ini->variable('SCMSettings', 'RepoDir');
if ($dir !== '')
$dir = $ini->variable( 'SCMSettings', 'RepoDir' );
if ( $dir !== '' )
{
return $dir;
}

return is_dir( './.git' ) ? './.git' : ( is_dir( '../.git' ) && is_file( '../ezpublish/EzPublishKernel.php' ) ? '../.git' : false );
switch($type)
{
case 'git':
return is_dir( './.git' ) ? './.git' : ( is_dir( '../.git' ) && is_file( '../ezpublish/EzPublishKernel.php' ) ? '../.git' : false );
case 'file':
default:
eZDebug::writeError( "Can not find info from scm type '$type' with an empty directory", __METHOD__ );
return false;
}
}
}
2 changes: 1 addition & 1 deletion classes/inichecker.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2010-2016
* @copyright (C) G. Giunta 2010-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/phpchecker.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2010-2016
* @copyright (C) G. Giunta 2010-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/reportgenerator.php
Expand Up @@ -3,7 +3,7 @@
* A helper class for generating reports
*
* @author G. Giunta
* @copyright (C) G. Giunta 2012-2016
* @copyright (C) G. Giunta 2012-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/reports/ezcontentclassesreport.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/reports/ezinireport.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/reports/ezpoliciesreport.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/reports/ezworkflowsreport.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/statustests/sysinfotests.php
Expand Up @@ -2,7 +2,7 @@
/**
*
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/sysinfomodule.php
Expand Up @@ -3,7 +3,7 @@
* Class used to help managing in a single place all module/view info
*
* @author G. Giunta
* @copyright (C) G. Giunta 2010-2016
* @copyright (C) G. Giunta 2010-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/sysinfotools.php
Expand Up @@ -2,7 +2,7 @@
/**
*
* @author G. Giunta
* @copyright (C) G. Giunta 2008-2016
* @copyright (C) G. Giunta 2008-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/systemchecker.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/tplchecker.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/viewgroups/ezsysinfobaseviewgroup.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/viewgroups/ezsysinfodevelopmentviewgroup.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/viewgroups/ezsysinfoezpublishviewgroup.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/viewgroups/ezsysinfoindexviewgroup.php
@@ -1,7 +1,7 @@
<?php
/**
* @author G. Giunta
* @copyright (C) G. Giunta 2014-2016
* @copyright (C) G. Giunta 2014-2017
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

Expand Down

0 comments on commit e7260dc

Please sign in to comment.