$name, 'owner' => $owner, 'provider' => $provider ]; } public static function getRepoDetailsByUrl($url) { $url = trim($url); if (empty($url)) { return []; } shell_exec('GIT_TERMINAL_PROMPT=0'); $outputBranches = shell_exec('git ls-remote --heads '.$url); $outputTags = shell_exec('git ls-remote --tags '.$url); $branches = []; $tags = []; $gitUrl = self::parseGitUrl($url); foreach (explode("\n", $outputBranches) as $line) { if (empty($line)) { continue; } $parts = explode("\t", $line); $branch = str_replace('refs/heads/', '', $parts[1]); $branches[$branch] = $branch; } foreach (explode("\n", $outputTags) as $line) { if (empty($line)) { continue; } $parts = explode("\t", $line); $tag = str_replace('refs/tags/', '', $parts[1]); $tags[$tag] = $tag; } $output = [ 'branches' => $branches, 'tags' => $tags, 'name' => $gitUrl['name'], 'owner' => $gitUrl['owner'], 'provider' => $gitUrl['provider'] ]; return $output; } }