From 7fe0f3f13d437db7195fc2e61b913401ac5c1b57 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 6 Apr 2014 16:48:21 -0400 Subject: [PATCH] kde-projects: DRY refactor effective branch-group. --- modules/ksb/Application.pm | 9 +-------- modules/ksb/BuildContext.pm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm index 05cb9da..3bc629d 100644 --- a/modules/ksb/Application.pm +++ b/modules/ksb/Application.pm @@ -682,14 +682,7 @@ sub _resolveModuleDependencies @modules = eval { my $dependencyResolver = ksb::DependencyResolver->new(); - my $branchGroup = $ctx->getOption('branch-group', 'module') // ''; - if (!$branchGroup) { - $branchGroup = $ctx->getOption('use-stable-kde') - ? 'latest-qt4' - : ($ctx->hasOption('use-stable-kde') # Could also be false if unset - ? 'kf5-qt5' # Really set to false - : 'latest-qt4'); # Unset / this is default branch group if no option set - } + my $branchGroup = $ctx->effectiveBranchGroup(); for my $file ('dependency-data-common', "dependency-data-$branchGroup") { diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm index dfbb45a..1bfc89b 100644 --- a/modules/ksb/BuildContext.pm +++ b/modules/ksb/BuildContext.pm @@ -951,6 +951,25 @@ sub setKDEProjectMetadataModuleNeeded return; } +# Returns the effective branch group to use for modules. You should not call +# this unless kde-build-metadata is also in use (see +# setKDEProjectMetadataModule and moduleBranchGroupResolver). +sub effectiveBranchGroup +{ + my $self = shift; + my $branchGroup = $self->getOption('branch-group', 'module') // ''; + + if (!$branchGroup) { + $branchGroup = $self->getOption('use-stable-kde') + ? 'latest-qt4' + : ($self->hasOption('use-stable-kde') # Could also be false if unset + ? 'kf5-qt5' # Really set to false + : 'latest-qt4'); # Unset / this is default branch group if no option set + } + + return $branchGroup; +} + # Returns a ksb::Module::BranchGroupResolver which can be used to efficiently # determine a git branch to use for a given kde-projects module (when the # branch-group option is in use), as specified at