Skip to content

Commit

Permalink
Features view: add develop-exo as base branch with cherry commits cal…
Browse files Browse the repository at this point in the history
…culation to fit with reverse rebase (#240)
  • Loading branch information
hbenali authored Oct 3, 2024
1 parent 12b9188 commit 3ea31ac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
3 changes: 2 additions & 1 deletion var/www/features.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@
foreach ($baseBranches as $baseBranch => $BaseProjects) {
$ciView = getBaseBranchView($baseBranch);
$rebaseJobName = getRebaseJobName($baseBranch);
$cherryCompare = isCherryCompare($baseBranch);
?>
<tr>
<td><a name="<?=str_replace(array("/", "."), "-", $baseBranch)?>"/><a href="<?=currentPageURL() . "#" . str_replace(array("/", "."), "-", $baseBranch)?>"><i class="icon-bookmark"></i></a>&nbsp;<?=$baseBranch?><br/><a href='https://ci.exoplatform.org/job/<?=$rebaseJobName?>' target="_blank" title="Rebase FB" rel="tooltip"><i class="icon-refresh"></i></a><br/><img src='https://ci.exoplatform.org/buildStatus/icon?job=<?=$rebaseJobName?>' style="height:15px; width: 85px;"></td>
<?php foreach ($projects as $project) { ?>
<td class="col-center">
<?php if (array_key_exists($project, $BaseProjects)) { ?>
<?= componentFeatureRepoBrancheStatus($BaseProjects[$project]);?>
<?= componentFeatureRepoBrancheStatus($BaseProjects[$project], $cherryCompare);?>
<a href='https://ci.exoplatform.org/job/<?=$ciView?>/job/<?=getModuleCiPrefix($project)?><?=$project?>-<?=$baseBranch?>-ci/' target="_blank" title="CI" rel="tooltip" title="Continuous integration job"><img src='https://ci.exoplatform.org/buildStatus/icon?job=<?=$ciView?>/<?=getModuleCiPrefix($project)?><?=$project?>-<?=$baseBranch?>-ci'></a>
<?php }?>
</td>
Expand Down
14 changes: 13 additions & 1 deletion var/www/lib/functions-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,23 @@ function componentFBDeployIcon($deployment_descriptor) {
* Get markup for a Git repository branch commits status
*
* @param $fb_project
* @param $cherry_commits_display
*
* @return string html markup
*/
function componentFeatureRepoBrancheStatus($fb_project) {
function componentFeatureRepoBrancheStatus($fb_project, $cherry_commits_display = false) {
$content="";

if($cherry_commits_display) {
$content.='<span rel="tooltip" title="Some commits on the base branch that do not exist on this branch [cherry-compare]">';
if ($fb_project['cherry_commits'] > 0) {
$content.='<span class="label label-commit label-important"><i class="icon-arrow-down icon-white"></i></span>';
} else {
$content.='<span class="label label-commit"><i class="icon-arrow-down"></i></span>';
}
$content.='</span>';
return $content;
}

$content='<a href="'.$fb_project['http_url_behind'].'" target="_blank" title="[behind]">';
$content.='<span rel="tooltip" title="'.$fb_project['behind_commits'].' commits on the base branch that do not exist on this branch [behind]">';
Expand Down
28 changes: 26 additions & 2 deletions var/www/lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ function isFeature($branch)
function isBaseBranch($branch)
{
// All brase branches must be on the origin (see bug: SWF-2520)
// TO-DO Add develop-exo
return strpos($branch, "origin/develop-meed") !== false ;
return strpos($branch, "origin/develop-meed") !== false || strpos($branch, "origin/develop-exo") !== false ;
}

function isTranslation($branch)
Expand Down Expand Up @@ -361,6 +360,11 @@ function getBaseBranches($projects)
$basebranches[$branch][$project]['ahead_commits'] = 0;
else
$basebranches[$branch][$project]['ahead_commits'] = count(explode("\n", $ahead_commits_logs));
$cherry_commits_logs = $repoObject->git("log --cherry origin/" . $branch . "..origin/" . $baseBranchToCompareWith . " --oneline");
if (empty($cherry_commits_logs))
$basebranches[$branch][$project]['cherry_commits'] = 0;
else
$basebranches[$branch][$project]['cherry_commits'] = count(explode("\n", $cherry_commits_logs));
}
}
uksort($basebranches, 'strcasecmp');
Expand Down Expand Up @@ -1613,4 +1617,24 @@ function getRebaseJobName($branch) {
return null;
}

/**
* Return if cherry commits compare is required
*
* @param $branch base branch name
*
* @return boolean
*/

function isCherryCompare($branch) {

$rebaseJobName = array(
"develop-exo" => true,
"develop-meed" => false
);
if(isset($rebaseJobName[$branch])) {
return $rebaseJobName[$branch];
}
return false;
}

?>

0 comments on commit 3ea31ac

Please sign in to comment.