Output the branch a particular commit is on; this is easy for

mercurial and monotone, but slightly harder till impossible to
do properly for git and svn. Please review and eventually adapt
the code to make it work better (partially fixes issue 450)
This commit is contained in:
Thomas Keller 2010-11-17 01:53:17 +01:00
parent ad15b13f7e
commit 70e8d12420
5 changed files with 16 additions and 5 deletions

View File

@ -436,6 +436,8 @@ class IDF_Scm_Git extends IDF_Scm
$out = self::parseLog($out); $out = self::parseLog($out);
$out[0]->changes = ''; $out[0]->changes = '';
} }
$out[0]['branch'] = $this->inBranches($commit, null);
return $out[0]; return $out[0];
} }

View File

@ -429,6 +429,8 @@ class IDF_Scm_Mercurial extends IDF_Scm
$c['author'] = $match[2]; $c['author'] = $match[2];
} elseif ($match[1] == 'summary') { } elseif ($match[1] == 'summary') {
$c['title'] = $match[2]; $c['title'] = $match[2];
} elseif ($match[1] == 'branch') {
$c['branch'] = $match[2];
} else { } else {
$c[$match[1]] = trim($match[2]); $c[$match[1]] = trim($match[2]);
} }
@ -443,6 +445,7 @@ class IDF_Scm_Mercurial extends IDF_Scm
} }
} }
$c['tree'] = !empty($c['commit']) ? trim($c['commit']) : ''; $c['tree'] = !empty($c['commit']) ? trim($c['commit']) : '';
$c['branch'] = empty($c['branch']) ? 'default' : $c['branch'];
$c['full_message'] = !empty($c['full_message']) ? trim($c['full_message']) : ''; $c['full_message'] = !empty($c['full_message']) ? trim($c['full_message']) : '';
$res[] = (object) $c; $res[] = (object) $c;
return $res; return $res;

View File

@ -623,7 +623,9 @@ class IDF_Scm_Monotone extends IDF_Scm
$res['title'] = $split[0]; $res['title'] = $split[0];
$res['full_message'] = (isset($split[1])) ? trim($split[1]) : ''; $res['full_message'] = (isset($split[1])) ? trim($split[1]) : '';
$res['branch'] = implode(', ', $certs['branch']);
$res['commit'] = $revs[0]; $res['commit'] = $revs[0];
$res['changes'] = ($getdiff) ? $this->_getDiff($revs[0]) : ''; $res['changes'] = ($getdiff) ? $this->_getDiff($revs[0]) : '';
return (object) $res; return (object) $res;

View File

@ -415,6 +415,7 @@ class IDF_Scm_Svn extends IDF_Scm
$res['commit'] = (string) $xml->logentry['revision']; $res['commit'] = (string) $xml->logentry['revision'];
$res['changes'] = ($getdiff) ? $this->getDiff($commit) : ''; $res['changes'] = ($getdiff) ? $this->getDiff($commit) : '';
$res['tree'] = ''; $res['tree'] = '';
$res['branch'] = '';
return (object) $res; return (object) $res;
} }

View File

@ -10,6 +10,9 @@
<th><strong>{trans 'Author:'}</strong></th><td>{showuser $rcommit.get_author(), $request, $cobject.author}</td> <th><strong>{trans 'Author:'}</strong></th><td>{showuser $rcommit.get_author(), $request, $cobject.author}</td>
</tr> </tr>
<tr> <tr>
<th><strong>{trans 'Branch:'}</strong></th><td>{$cobject.branch}</td>
</tr>
<tr>
<th><strong>{trans 'Commit:'}</strong></th><td class="mono"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}" title="{trans 'View corresponding source tree'}">{$cobject.commit}</a></td> <th><strong>{trans 'Commit:'}</strong></th><td class="mono"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}" title="{trans 'View corresponding source tree'}">{$cobject.commit}</a></td>
</tr> </tr>
<tr> <tr>