protected function getBranchSpecificPlugins(&$config, $stage, $pluginsToExecute)
    {
        /** @var \PHPCI\Model\Build $build */
        $build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
        $branch = $build->getBranch();

        // If we don't have any branch-specific plugins:
        if (!isset($config['branch-' . $branch][$stage]) || !is_array($config['branch-' . $branch][$stage])) {
            return $pluginsToExecute;
        }

        // If we have branch-specific plugins to execute, add them to the list to be executed:
        $branchConfig = $config['branch-' . $branch];
        $plugins = $branchConfig[$stage];

        $runOption = 'after';

        if (!empty($branchConfig['run-option'])) {
            $runOption = $branchConfig['run-option'];
        }

        switch ($runOption) {
            // Replace standard plugin set for this stage with just the branch-specific ones:
            case 'replace':
                $pluginsToExecute = array();
                $pluginsToExecute[] = $plugins;
                break;

            // Run branch-specific plugins before standard plugins:
            case 'before':
                array_unshift($pluginsToExecute, $plugins);
                break;

            // Run branch-specific plugins after standard plugins:
            case 'after':
                array_push($pluginsToExecute, $plugins);
                break;

            default:
                array_push($pluginsToExecute, $plugins);
                break;
        }

        return $pluginsToExecute;
    }