return $this->status;
}
- public function getRevisionId() {
+ public function getRevisionID() {
return $this->revisionID;
}
return $this->commitSubject;
}
+ public function getCommitDisplayName() {
+ if ($this->revisionID) {
+ return 'D'.$this->revisionID.': '.$this->commitSubject;
+ } else {
+ return $this->commitSubject;
+ }
+ }
+
public function getCommitAuthor() {
return $this->commitAuthor;
}
$result = array();
foreach ($lines as $line) {
$match = array();
- $branch = array();
- preg_match('/^(\*?)\s*(\S+)/', $line, $match);
- $branch['current'] = !empty($match[1]);
- $branch['name'] = $match[2];
- $result[] = $branch;
+ preg_match('/^(\*?)\s*(.*)$/', $line, $match);
+ $name = $match[2];
+ if ($name == '(no branch)') {
+ // Just ignore this, we could theoretically try to figure out the ref
+ // and treat it like a real branch but that's sort of ridiculous.
+ continue;
+ }
+ $result[] = array(
+ 'current' => !empty($match[1]),
+ 'name' => $name,
+ );
}
$all_names = ipull($result, 'name');
// Calling 'git branch' first and then 'git rev-parse' is way faster than
continue;
}
- $rev_id = $branch->getRevisionId();
+ $rev_id = $branch->getRevisionID();
if ($rev_id) {
$status = idx($revision_status, $rev_id, 'Unknown Status');
$branch->setStatus($status);
echo reset($branches)->getFormattedStatus()."\n";
foreach ($branches as $branch) {
$name_markdown = $branch->getFormattedName();
- $subject = $branch->getCommitSubject();
+ $subject = $branch->getCommitDisplayName();
$name_markdown = str_pad($name_markdown, $longest_name + 4, ' ');
echo " $name_markdown $subject\n";
}
foreach ($this->branches as $branch) {
$name_markdown = $branch->getFormattedName();
$status_markdown = $branch->getFormattedStatus();
- $subject = $branch->getCommitSubject();
+ $subject = $branch->getCommitDisplayName();
$subject_pad = $longest_status - strlen($branch->getStatus()) + 4;
$name_markdown =
str_pad($name_markdown, $longest_name + 4, ' ');