From 3ea31ac5e3c420f914f595a5f210e016148f9f9a Mon Sep 17 00:00:00 2001 From: Houssem Ben Ali Date: Thu, 3 Oct 2024 18:00:06 +0200 Subject: [PATCH] Features view: add develop-exo as base branch with cherry commits calculation to fit with reverse rebase (#240) --- var/www/features.php | 3 ++- var/www/lib/functions-ui.php | 14 +++++++++++++- var/www/lib/functions.php | 28 ++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/var/www/features.php b/var/www/features.php index 9fb71d26..42201e6f 100644 --- a/var/www/features.php +++ b/var/www/features.php @@ -146,13 +146,14 @@ foreach ($baseBranches as $baseBranch => $BaseProjects) { $ciView = getBaseBranchView($baseBranch); $rebaseJobName = getRebaseJobName($baseBranch); + $cherryCompare = isCherryCompare($baseBranch); ?> "/>"> 

- + diff --git a/var/www/lib/functions-ui.php b/var/www/lib/functions-ui.php index d23b96f1..30ee8790 100644 --- a/var/www/lib/functions-ui.php +++ b/var/www/lib/functions-ui.php @@ -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.=''; + if ($fb_project['cherry_commits'] > 0) { + $content.=''; + } else { + $content.=''; + } + $content.=''; + return $content; + } $content=''; $content.=''; diff --git a/var/www/lib/functions.php b/var/www/lib/functions.php index 9e1afb3b..4aa10d2b 100644 --- a/var/www/lib/functions.php +++ b/var/www/lib/functions.php @@ -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) @@ -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'); @@ -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; +} + ?>