Skip to content

Commit 9a96d17

Browse files
committed
added list_remote_branches()
1 parent b5e09b3 commit 9a96d17

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Git.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,25 @@ public function list_branches($keep_asterisk = false) {
388388
return $branchArray;
389389
}
390390

391+
/**
392+
* Lists remote branches (using `git branch -r`).
393+
*
394+
* Also strips out the HEAD reference (e.g. "origin/HEAD -> origin/master").
395+
*
396+
* @access public
397+
* @return array
398+
*/
399+
public function list_remote_branches() {
400+
$branchArray = explode("\n", $this->run("branch -r"));
401+
foreach($branchArray as $i => &$branch) {
402+
$branch = trim($branch);
403+
if ($branch == "" || strpos($branch, 'HEAD -> ') !== false) {
404+
unset($branchArray[$i]);
405+
}
406+
}
407+
return $branchArray;
408+
}
409+
391410
/**
392411
* Returns name of active branch
393412
*
@@ -507,4 +526,4 @@ public function get_description() {
507526

508527
}
509528

510-
/* End of file */
529+
/* End of file */

0 commit comments

Comments
 (0)