Skip to content

Commit

Permalink
enable by default the scm-info panel if git info is found
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Feb 16, 2016
1 parent 1a85955 commit 0d3d754
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 22 deletions.
62 changes: 62 additions & 0 deletions classes/ezsysinfoscmchecker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

class eZSysinfoSCMChecker implements ezSysinfoReport
{
public function getReport()
{

}

/**
* @return array:
* - 'tag'
* - 'title'
* - 'executingString'
* - 'format' byrow, byline or html for now
*/
public function getDescription()
{

}

/**
* @todo add check that 'git' is executable
* @return bool
*/
public static function hasScmInfo()
{
return self::getScmDir() != false ? true : false;
}

/**
* @return array
*/
public static function getScmInfo()
{
$dir = self::getScmDir();
if (!$dir) {
return array();
}

$revisionInfo = array();
exec( "cd $dir && git log -1", $revisionInfo, $retcode );


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

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

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

protected static function getScmDir()
{
return is_dir('./.git') ? './.git' : (is_dir('../.git') && is_file('../ezpublish/EzPublishKernel.php') ? '../.git' : false);
}
}
1 change: 0 additions & 1 deletion classes/inichecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,3 @@ protected static function parseIniFile( $filename, &$warnings, $isphp=false )
}

}
?>
1 change: 0 additions & 1 deletion classes/phpchecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,3 @@ protected static function parsePhpFile( $filename, &$warnings, $checksyntax=true
}

}
?>
2 changes: 0 additions & 2 deletions classes/reportgenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,3 @@ public function formatBytes( $size, $precision = 2 )
return round( pow( 1024, $base - floor( $base ) ), $precision ) . $suffixes[floor( $base )];
}
}

?>
7 changes: 5 additions & 2 deletions classes/sysinfomodule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
* @license Licensed under GNU General Public License v2.0. See file license.txt
*/

class sysinfoModule{
/**
* @deprecated
*/
class sysinfoModule
{

static $initialized = false;

Expand Down Expand Up @@ -476,4 +480,3 @@ static function viewActive( $viewname )
return false;
}
}
?>
1 change: 0 additions & 1 deletion classes/sysinfotools.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,3 @@ public static function eZTemplateFactory()

static $ezpClasses = false;
}
?>
2 changes: 0 additions & 2 deletions classes/systemchecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,3 @@ static function checkSetupRequirements()
}

}

?>
1 change: 0 additions & 1 deletion classes/tplchecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ protected static function parseTplFile( $filename, &$warnings )
}

}
?>
9 changes: 9 additions & 0 deletions classes/viewgroups/ezsysinfoezpublishviewgroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ protected static function initialize()
self::$view_groups['clustercachestats']['hidden'] = true;
self::$view_groups['clusterstoragestats']['hidden'] = true;
}
if ( eZSysinfoSCMChecker::hasScmInfo()) {
self::$view_groups['sourcerevision'] = array(
'script' => 'genericview.php',
'default_navigation_part' => 'ezsysinfonavigationpart',
//'unordered_params' => array( 'view' => 'viewmode' ),
'name' => 'SCM Info',
'description' => 'Information about the Source Control System current Revision'
);
}

// a bit hackish...
if ( count( ezSysinfoClusterManager::clusterNodes() ) && ! ezSysinfoClusterManager::isClusterSlaveRequest() )
Expand Down
11 changes: 6 additions & 5 deletions design/standard/templates/sysinfo/sourcerevision.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<tr>
<th>GIT Revision</th>
</tr>
{foreach $revision_info as $result sequence array( 'bglight', 'bgdark') as $style}
{foreach $info.revision_info as $result sequence array( 'bglight', 'bgdark') as $style}
<tr class="{$style}">
<td>{$result|wash()}</td>
</tr>
Expand All @@ -32,7 +32,7 @@
<tr>
<th>GIT Status</th>
</tr>
{foreach $status_info as $result sequence array( 'bglight', 'bgdark') as $style}
{foreach $info.status_info as $result sequence array( 'bglight', 'bgdark') as $style}
<tr class="{$style}">
<td>{$result|wash()}</td>
</tr>
Expand All @@ -43,7 +43,7 @@
<tr>
<th>GIT Tag</th>
</tr>
{foreach $tag_info as $result sequence array( 'bglight', 'bgdark') as $style}
{foreach $info.tag_info as $result sequence array( 'bglight', 'bgdark') as $style}
<tr class="{$style}">
<td>{$result|wash()}</td>
</tr>
Expand All @@ -54,8 +54,9 @@

</div>


<p>Full history of source code is available at: <a href="https://bitbucket.org/itmebusiness/ovumkc">ITMEBusiness Bitbucket</a></p>
{if ne('', ezini('SCMSettings', 'RepoLink', 'sysinfo.ini'))}
<p>Full history of source code is available at: <a href="{ezini('SCMSettings', 'RepoLink', 'sysinfo.ini')|wash()}">{ezini('SCMSettings', 'RepoName', 'sysinfo.ini')|wash()}</a></p>
{/endif}

{* DESIGN: Content END *}</div></div></div></div></div></div>

Expand Down
11 changes: 4 additions & 7 deletions modules/sysinfo/sourcerevision.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php
/**
* User: gaetano.giunta
* Date: 24/04/14
* Time: 17.33
*/

$revisionInfo = array();
/*$revisionInfo = array();
$retcode = 0;
exec( "cd .. && git log -1", $revisionInfo, $retcode );
Expand All @@ -19,4 +14,6 @@
$tpl->setVariable( 'revision_info', $revisionInfo );
$tpl->setVariable( 'status_info', $statusInfo );
$tpl->setVariable( 'tag_info', $tagInfo );
$tpl->setVariable( 'tag_info', $tagInfo );*/

$tpl->setVariable( 'info', eZSysinfoSCMChecker::getScmInfo() );
5 changes: 5 additions & 0 deletions settings/sysinfo.ini
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,8 @@ DataRetrieval=server2server
TokenSecret=ChangeMePlease
# seconds of validity for auth tokens used for intra-node communications in cluster
TokenTTL=300

[SCMSettings]
#used in the tpl for SCM INFO
RepoLink=
RepoName=

0 comments on commit 0d3d754

Please sign in to comment.