Skip to content

Commit b9ea7bf

Browse files
committed
Add a method to get branches of a repo
1 parent 937acd0 commit b9ea7bf

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

modules/git_analyzer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ function get_log($custom_params = array()) {
9191
return $logs;
9292
}
9393

94+
function get_branches() {
95+
96+
$params = $this->cmd->prepare_params();
97+
$params->worktree = $this->worktree;
98+
$output = $this->cmd->exec('branch', $params);
99+
return array_filter(preg_replace('/[\s\*]/', '', explode("\n", $output)));
100+
}
101+
94102
function get_log_by_range($since = '', $until = '') {
95103

96104
$params = array();

modules/git_command.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ private function git_show($param) {
8383
return $this->run($dir, $this->command, $param_string);
8484
}
8585

86+
private function git_branch($param) {
87+
88+
$dir = $this->get_worktree($param);
89+
$param_string = 'branch';
90+
foreach($param->other as $p) {
91+
$param_string .= ' '.$p;
92+
}
93+
return $this->run($dir, $this->command, $param_string);
94+
}
95+
8696
private function git_delete($param) {
8797

8898
$dir = $this->get_worktree($param);

0 commit comments

Comments
 (0)