Configures the package of branch.

@param string $branch The branch name
@param array  $data   The data

@return array
356979
protected function configureBranchPackage($branch, array $data)
    {
        $parsedBranch = $this->versionParser->normalizeBranch($branch);
        $data['version_normalized'] = $parsedBranch;

        // make sure branch packages have a dev flag
        if ('dev-' === substr((string) $parsedBranch, 0, 4) || '9999999-dev' === $parsedBranch) {
            $data['version'] = 'dev-'.$data['version'];
        } else {
            $data['version'] = preg_replace('{(\.9{7})+}', '.x', (string) $parsedBranch);
        }

        return $data;
    }
534711
protected static function setBranchOrder(array $order)
    {
        static::$branchOrder = array_flip(array_flatten($order));

        static::$branchOrder = array_map(function ($item) {
            return ++$item;
        }, static::$branchOrder);
    }
1207804
public function setBranch($value)
    {
        $this->_validateNotNull('Branch', $value);
        $this->_validateString('Branch', $value);

        if ($this->data['branch'] === $value) {
            return;
        }

        $this->data['branch'] = $value;

        $this->_setModified('branch');
    }
172125
protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
    {
        $branchType = null;

        foreach ($config as $key => $value) {
            if ($branchType === null) {
                if (is_numeric($key)) {
                    $branchType = 'numeric';
                    $branchName = $xml->getName();
                    $xml        = $parent;

                    unset($parent->{$branchName});
                } else {
                    $branchType = 'string';
                }
            } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
                // require_once 'Zend/Config/Exception.php';
                throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
            }

            if ($branchType === 'numeric') {
                if ($value instanceof Zend_Config) {
                    $child = $parent->addChild($branchName);

                    $this->_addBranch($value, $child, $parent);
                } else {
                    $parent->addChild($branchName, (string) $value);
                }
            } else {
                if ($value instanceof Zend_Config) {
                    $child = $xml->addChild($key);

                    $this->_addBranch($value, $child, $xml);
                } else {
                    $xml->addChild($key, (string) $value);
                }
            }
        }
    }
548723
public function insert(self $branch)
    {
        if (!\in_array($branch, $this->branches)) {
            $this->branches[] = $branch;
        }
    }
1221051
public function setConfigurationSection($package, $data)
	{
		if (!isset($this->configurationSections[$package])) {
			throw new \Exception(sprintf('There is no configuration section for package "%s"', $package));
		}

		$this->configurationSections[$package]['data'] = $data;
	}
1013709
public DataWriterBuilder<S, D> forBranch(int branch) {
    this.branch = branch;
    log.debug("For branch: {}", this.branch);
    return this;
  }
678244
public function publishBase($branch = null, $tag = null)
    {
        if (!$branch) {
            $branch = self::STABLE_BRANCH;
        }

        $this->say("Updating Codeception Base distribution");

        $tempBranch = "tmp".uniqid();

        $this->taskGitStack()
            ->checkout("-b $tempBranch")
            ->run();

        $this->taskReplaceInFile('composer.json')
            ->from('"codeception/codeception"')
            ->to('"codeception/base"')
            ->run();

        $this->taskReplaceInFile('composer.json')
            ->regex('~^\s+"facebook\/webdriver".*$~m')
            ->to('')
            ->run();

        $this->taskReplaceInFile('composer.json')
            ->regex('~^\s+"guzzlehttp\/guzzle".*$~m')
            ->to('')
            ->run();

        $this->taskComposerUpdate()->run();
        $this->taskGitStack()
            ->add('composer.json')
            ->commit('auto-update')
            ->exec("push -f base $tempBranch:$branch")
            ->run();

        if ($tag) {
            $this->taskGitStack()
                ->exec("tag -d $tag")
                ->exec("push base :refs/tags/$tag")
                ->exec("tag $tag")
                ->push('base', $tag)
                ->run();
        }

        $this->taskGitStack()
            ->checkout('-- composer.json')
            ->checkout($branch)
            ->exec("branch -D $tempBranch")
            ->run();
    }
860505
public static function config_get_configuration_array($data) {
        $config = array();

        if (isset($data->path)) {
            $config['path'] = $data->path;
        }
        if (isset($data->autocreate)) {
            $config['autocreate'] = $data->autocreate;
        }
        if (isset($data->singledirectory)) {
            $config['singledirectory'] = $data->singledirectory;
        }
        if (isset($data->prescan)) {
            $config['prescan'] = $data->prescan;
        }

        return $config;
    }
488701
public function parse_branch_response( $response ) {
		if ( $this->validate_response( $response ) ) {
			return $response;
		}
		$branches = [];
		foreach ( $response as $branch ) {
			$branches[ $branch->name ]['download']         = $this->construct_download_link( $branch->name );
			$branches[ $branch->name ]['commit_hash']      = $branch->target->hash;
			$branches[ $branch->name ]['commit_timestamp'] = $branch->target->date;
		}
		return $branches;
	}
338969
public function resolveBranchConfig(array $branchConfig)
    {
        $resolver = new OptionsResolver();
        $resolver
            ->setDefaults(array(
                'path' => null,
                'commands' => array(),
                'options' => array(),
            ))
            ->setAllowedTypes('commands', 'array')
            ->setAllowedTypes('options', 'array')
            ->setAllowedTypes('path', array('string', 'null'))
        ;

        try {
            return $resolver->resolve($branchConfig);
        } catch (InvalidArgumentException $exception) {
            $this->logger->critical('Couldn\'t resolve branch config: '.$exception->getTraceAsString());
            throw $exception;
        }
    }
352548
public function findBranchByNodeId(Branch $tree, $nodeId)
    {
        foreach ($tree->getChildren() as $branch) {
            if ($branch->getNodeId() == $nodeId) {
                return $branch;
            }

            // recursive search:
            $branch = $this->findBranchByNodeId($branch, $nodeId);
            if ($branch) {
                return $branch;
            }
        }

        return null;
    }
375620
public function setBranch($branch)
    {
        $request = new Request($this->handler);
        $this->branch = $request->execute(
            RequestMethods::HTTP_PUT,
            $this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
            [
                'json' => [
                    'id' => $branch,
                ],
                'headers' => [
                    'X-Session-ID' => $this->getToken()
                ]
            ]
        )->id;

        return $this;
    }
890007
protected function serializeBranch(array $branch)
	{
		// Optimize away "else{}" completely
		if ($branch['structure'] === 'else'
		 && $branch['body']      === ''
		 && empty($branch['head'])
		 && empty($branch['tail']))
		{
			return '';
		}

		return $branch['structure'] . '{' . $this->serializeOutput($branch['head']) . $branch['body'] . $this->serializeOutput(array_reverse($branch['tail'])) . '}';
	}
595060
public function getSelectedBuild($data) {
		if(isset($data['SelectRelease']) && !empty($data[$data['SelectRelease']])) {
			// Filter out the tag/branch name if required
			$array = explode('-', $data[$data['SelectRelease']]);
			return reset($array);
		}
		if(isset($data['FilteredCommits']) && !empty($data['FilteredCommits'])) {
			return $data['FilteredCommits'];
		}
	}
1170908
public function setBranches($name, $branch, $add = false)
    {
        $this->arguments[] = 'set-branches';
        if ($add) {
            $this->arguments[] = '--add';
        }
        $this->arguments[] = $name;
        $this->arguments[] = $branch;
        return $this;
    }
184239
public function plugin_branch_switcher( $plugin_file, $plugin_data ) {
		if ( empty( static::$options['branch_switch'] ) ) {
			return false;
		}

		$enclosure         = $this->update_row_enclosure( $plugin_file, 'plugin', true );
		$plugin            = $this->get_repo_slugs( dirname( $plugin_file ) );
		$nonced_update_url = wp_nonce_url(
			$this->get_update_url( 'plugin', 'upgrade-plugin', $plugin_file ),
			'upgrade-plugin_' . $plugin_file
		);

		if ( ! empty( $plugin ) ) {
			$id       = $plugin['slug'] . '-id';
			$branches = isset( $this->config[ $plugin['slug'] ]->branches )
				? $this->config[ $plugin['slug'] ]->branches
				: null;
		} else {
			return false;
		}

		// Get current branch.
		$repo   = $this->config[ $plugin['slug'] ];
		$branch = Singleton::get_instance( 'Branch', $this )->get_current_branch( $repo );

		$branch_switch_data                      = [];
		$branch_switch_data['slug']              = $plugin['slug'];
		$branch_switch_data['nonced_update_url'] = $nonced_update_url;
		$branch_switch_data['id']                = $id;
		$branch_switch_data['branch']            = $branch;
		$branch_switch_data['branches']          = $branches;

		/*
		 * Create after_plugin_row_
		 */
		echo $enclosure['open'];
		$this->make_branch_switch_row( $branch_switch_data );
		echo $enclosure['close'];

		return true;
	}