Пример #1
0
<?php 
include_once V2_INC . '/property.php';
@(include_once V2_PLUGIN . "/code/ui.php");
@(include_once V2_PLUGIN . "/code/settings.php");
$id = $_GET['id'];
$dir = REPOSITORY . '/' . $id . '/';
use Cz\Git\GitRepository;
$repo = new GitRepository($dir);
$branches = $repo->getBranches();
$current_branch = $repo->getCurrentBranchName();
$branch_list = array();
foreach ($branches as $branch) {
    if (strpos($branch, 'HEAD') !== false) {
        continue;
    }
    if (strpos($branch, 'remotes/') !== false) {
        $arr = explode("/", $branch);
        $branch_type = array_shift($arr);
        $origin = array_shift($arr);
        $branch_name = implode("/", $arr);
        $branch_list[] = array('value' => $branch_name, 'text' => $branch_name, 'type' => 'remote', 'origin' => $origin, 'selected' => $branch_name == $current_branch);
    }
}
if (sizeof($branch_list) == 0) {
    $branches = $repo->getLocalBranches();
    $branch_list = array();
    foreach ($branches as $branch) {
        $branch_list[] = array('value' => $branch, 'text' => $branch, 'type' => 'local', 'selected' => $branch == $current_branch);
    }
}