Added ticket 271, support of the Git tags.
This commit is contained in:
parent
73dba2fa1a
commit
8050463a12
2
AUTHORS
2
AUTHORS
@ -10,7 +10,7 @@ Much appreciated contributors:
|
|||||||
Julien Issler
|
Julien Issler
|
||||||
Manuel Eidenberger <eidenberger@gmail.com>
|
Manuel Eidenberger <eidenberger@gmail.com>
|
||||||
Ciaran Gultnieks
|
Ciaran Gultnieks
|
||||||
Mehdi Kabab
|
Mehdi Kabab <http://pioupioum.fr/>
|
||||||
Sindre R. Myren
|
Sindre R. Myren
|
||||||
Patrick Georgi <patrick.georgi@coresystems.de>
|
Patrick Georgi <patrick.georgi@coresystems.de>
|
||||||
Adrien Bustany
|
Adrien Bustany
|
||||||
|
@ -202,6 +202,24 @@ class IDF_Scm
|
|||||||
throw new Pluf_Exception_NotImplemented();
|
throw new Pluf_Exception_NotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns in which tags a commit/path is.
|
||||||
|
*
|
||||||
|
* A commit can be in several tags and some of the SCMs are
|
||||||
|
* managing tags using subfolders (like Subversion).
|
||||||
|
*
|
||||||
|
* This means that to know in which tag we are at the moment,
|
||||||
|
* one needs to have both the path and the commit.
|
||||||
|
*
|
||||||
|
* @param string Commit
|
||||||
|
* @param string Path
|
||||||
|
* @return array Tags
|
||||||
|
*/
|
||||||
|
public function inTags($commit, $path)
|
||||||
|
{
|
||||||
|
throw new Pluf_Exception_NotImplemented();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the main branch.
|
* Returns the main branch.
|
||||||
*
|
*
|
||||||
|
@ -91,14 +91,15 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
|
|
||||||
public function getMainBranch()
|
public function getMainBranch()
|
||||||
{
|
{
|
||||||
$possible = array('master', 'main', 'trunk', 'local');
|
$branches = $this->getBranches();
|
||||||
$branches = array_keys($this->getBranches());
|
if (array_key_exists('master', $branches))
|
||||||
foreach ($possible as $p) {
|
return 'master';
|
||||||
if (in_array($p, $branches)) {
|
static $possible = array('main', 'trunk', 'local');
|
||||||
return $p;
|
for ($i = 0; 3 > $i; ++$i) {
|
||||||
}
|
if (array_key_exists($possible[$i], $branches))
|
||||||
|
return $possible[$i];
|
||||||
}
|
}
|
||||||
return (isset($branches[0])) ? $branches[0] : 'master';
|
return key($branches);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,10 +110,75 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
*/
|
*/
|
||||||
public function inBranches($commit, $path)
|
public function inBranches($commit, $path)
|
||||||
{
|
{
|
||||||
return (in_array($commit, array_keys($this->getBranches())))
|
return $this->_inObject($commit, 'branch');
|
||||||
? array($commit) : array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IDF_Scm::getTags()
|
||||||
|
**/
|
||||||
|
public function getTags()
|
||||||
|
{
|
||||||
|
if (isset($this->cache['tags'])) {
|
||||||
|
return $this->cache['tags'];
|
||||||
|
}
|
||||||
|
$cmd = Pluf::f('idf_exec_cmd_prefix', '')
|
||||||
|
.sprintf('GIT_DIR=%s %s tag',
|
||||||
|
escapeshellarg($this->repo),
|
||||||
|
Pluf::f('git_path', 'git'));
|
||||||
|
exec($cmd, $out, $return);
|
||||||
|
if (0 != $return) {
|
||||||
|
throw new IDF_Scm_Exception(sprintf($this->error_tpl,
|
||||||
|
$cmd,
|
||||||
|
$return,
|
||||||
|
implode("\n", $out)));
|
||||||
|
}
|
||||||
|
$res = array();
|
||||||
|
foreach ($out as $b) {
|
||||||
|
if (false !== strpos($b, '/')) {
|
||||||
|
$res[$this->getCommit($b)->commit] = $b;
|
||||||
|
} else {
|
||||||
|
$res[$b] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->cache['tags'] = $res;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IDF_Scm::inTags()
|
||||||
|
**/
|
||||||
|
public function inTags($commit, $path)
|
||||||
|
{
|
||||||
|
return $this->_inObject($commit, 'tag');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns in which branches or tags a commit is.
|
||||||
|
*
|
||||||
|
* @param string Commit
|
||||||
|
* @param string Object's type: 'branch' or 'tag'.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function _inObject($commit, $object)
|
||||||
|
{
|
||||||
|
$object = strtolower($object);
|
||||||
|
if ('branch' === $object) {
|
||||||
|
$objects = $this->getBranches();
|
||||||
|
} else if ('tag' === $object) {
|
||||||
|
$objects = $this->getTags();
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException(sprintf(__('Invalid value for the parameter %1$s: %2$s. Use %3$s.'),
|
||||||
|
'$object',
|
||||||
|
$object,
|
||||||
|
'\'branch\' or \'tag\''));
|
||||||
|
}
|
||||||
|
unset($object);
|
||||||
|
$result = array();
|
||||||
|
if (array_key_exists($commit, $objects)) {
|
||||||
|
$result[] = $commit;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git "tree" is not the same as the tree we get here.
|
* Git "tree" is not the same as the tree we get here.
|
||||||
@ -226,14 +292,15 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
|
|
||||||
public function isValidRevision($commit)
|
public function isValidRevision($commit)
|
||||||
{
|
{
|
||||||
return ('commit' == $this->testHash($commit));
|
$type = $this->testHash($commit);
|
||||||
|
return ('commit' == $type || 'tag' == $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a given object hash.
|
* Test a given object hash.
|
||||||
*
|
*
|
||||||
* @param string Object hash.
|
* @param string Object hash.
|
||||||
* @return mixed false if not valid or 'blob', 'tree', 'commit'
|
* @return mixed false if not valid or 'blob', 'tree', 'commit', 'tag'
|
||||||
*/
|
*/
|
||||||
public function testHash($hash)
|
public function testHash($hash)
|
||||||
{
|
{
|
||||||
@ -257,7 +324,7 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
*/
|
*/
|
||||||
public function getTreeInfo($tree, $folder='')
|
public function getTreeInfo($tree, $folder='')
|
||||||
{
|
{
|
||||||
if (!in_array($this->testHash($tree), array('tree', 'commit'))) {
|
if (!in_array($this->testHash($tree), array('tree', 'commit', 'tag'))) {
|
||||||
throw new Exception(sprintf(__('Not a valid tree: %s.'), $tree));
|
throw new Exception(sprintf(__('Not a valid tree: %s.'), $tree));
|
||||||
}
|
}
|
||||||
$cmd_tmpl = 'GIT_DIR=%s '.Pluf::f('git_path', 'git').' ls-tree -l %s %s';
|
$cmd_tmpl = 'GIT_DIR=%s '.Pluf::f('git_path', 'git').' ls-tree -l %s %s';
|
||||||
@ -276,7 +343,6 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the file info.
|
* Get the file info.
|
||||||
*
|
*
|
||||||
@ -315,7 +381,6 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
return ($cmd_only) ? $cmd : shell_exec($cmd);
|
return ($cmd_only) ? $cmd : shell_exec($cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get commit details.
|
* Get commit details.
|
||||||
*
|
*
|
||||||
@ -342,21 +407,26 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
if ($ret != 0 or count($out) == 0) {
|
if ($ret != 0 or count($out) == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$log = array();
|
if ($getdiff) {
|
||||||
$change = array();
|
$log = array();
|
||||||
$inchange = false;
|
$change = array();
|
||||||
foreach ($out as $line) {
|
$inchange = false;
|
||||||
if (!$inchange and 0 === strpos($line, 'diff --git a')) {
|
foreach ($out as $line) {
|
||||||
$inchange = true;
|
if (!$inchange and 0 === strpos($line, 'diff --git a')) {
|
||||||
}
|
$inchange = true;
|
||||||
if ($inchange) {
|
}
|
||||||
$change[] = $line;
|
if ($inchange) {
|
||||||
} else {
|
$change[] = $line;
|
||||||
$log[] = $line;
|
} else {
|
||||||
|
$log[] = $line;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$out = self::parseLog($log);
|
||||||
|
$out[0]->changes = implode("\n", $change);
|
||||||
|
} else {
|
||||||
|
$out = self::parseLog($out);
|
||||||
|
$out[0]->changes = '';
|
||||||
}
|
}
|
||||||
$out = self::parseLog($log, 4);
|
|
||||||
$out[0]->changes = implode("\n", $change);
|
|
||||||
return $out[0];
|
return $out[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +478,7 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
$out = array();
|
$out = array();
|
||||||
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
|
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
|
||||||
exec($cmd, $out);
|
exec($cmd, $out);
|
||||||
return self::parseLog($out, 4);
|
return self::parseLog($out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -478,7 +548,7 @@ class IDF_Scm_Git extends IDF_Scm
|
|||||||
* Specific Git Commands
|
* Specific Git Commands
|
||||||
* =====================================================
|
* =====================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get submodule details.
|
* Get submodule details.
|
||||||
*
|
*
|
||||||
|
@ -62,8 +62,6 @@ class IDF_Views_Source
|
|||||||
public $changeLog_precond = array('IDF_Precondition::accessSource');
|
public $changeLog_precond = array('IDF_Precondition::accessSource');
|
||||||
public function changeLog($request, $match)
|
public function changeLog($request, $match)
|
||||||
{
|
{
|
||||||
$title = sprintf(__('%1$s %2$s Change Log'), (string) $request->project,
|
|
||||||
$this->getScmType($request));
|
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
if (!$scm->isAvailable()) {
|
if (!$scm->isAvailable()) {
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::help',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::help',
|
||||||
@ -85,6 +83,8 @@ class IDF_Views_Source
|
|||||||
$scm->getMainBranch()));
|
$scm->getMainBranch()));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
|
$title = sprintf(__('%1$s %2$s Change Log'), (string) $request->project,
|
||||||
|
$this->getScmType($request));
|
||||||
$changes = $scm->getChangeLog($commit, 25);
|
$changes = $scm->getChangeLog($commit, 25);
|
||||||
$rchanges = array();
|
$rchanges = array();
|
||||||
// Sync with the database
|
// Sync with the database
|
||||||
@ -94,6 +94,8 @@ class IDF_Views_Source
|
|||||||
$rchanges = new Pluf_Template_ContextVars($rchanges);
|
$rchanges = new Pluf_Template_ContextVars($rchanges);
|
||||||
$scmConf = $request->conf->getVal('scm', 'git');
|
$scmConf = $request->conf->getVal('scm', 'git');
|
||||||
$in_branches = $scm->inBranches($commit, '');
|
$in_branches = $scm->inBranches($commit, '');
|
||||||
|
$tags = $scm->getTags();
|
||||||
|
$in_tags = $scm->inTags($commit, '');
|
||||||
return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/changelog.html',
|
return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/changelog.html',
|
||||||
array(
|
array(
|
||||||
'page_title' => $title,
|
'page_title' => $title,
|
||||||
@ -102,6 +104,8 @@ class IDF_Views_Source
|
|||||||
'commit' => $commit,
|
'commit' => $commit,
|
||||||
'branches' => $branches,
|
'branches' => $branches,
|
||||||
'tree_in' => $in_branches,
|
'tree_in' => $in_branches,
|
||||||
|
'tags' => $tags,
|
||||||
|
'tags_in' => $in_tags,
|
||||||
'scm' => $scmConf,
|
'scm' => $scmConf,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
@ -110,8 +114,6 @@ class IDF_Views_Source
|
|||||||
public $treeBase_precond = array('IDF_Precondition::accessSource');
|
public $treeBase_precond = array('IDF_Precondition::accessSource');
|
||||||
public function treeBase($request, $match)
|
public function treeBase($request, $match)
|
||||||
{
|
{
|
||||||
$title = sprintf(__('%1$s %2$s Source Tree'),
|
|
||||||
$request->project, $this->getScmType($request));
|
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
if (!$scm->isAvailable()) {
|
if (!$scm->isAvailable()) {
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::help',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::help',
|
||||||
@ -126,8 +128,12 @@ class IDF_Views_Source
|
|||||||
$scm->getMainBranch()));
|
$scm->getMainBranch()));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
|
$title = sprintf(__('%1$s %2$s Source Tree'),
|
||||||
|
$request->project, $this->getScmType($request));
|
||||||
$branches = $scm->getBranches();
|
$branches = $scm->getBranches();
|
||||||
$in_branches = $scm->inBranches($commit, '');
|
$in_branches = $scm->inBranches($commit, '');
|
||||||
|
$tags = $scm->getTags();
|
||||||
|
$in_tags = $scm->inTags($commit, '');
|
||||||
$cache = Pluf_Cache::factory();
|
$cache = Pluf_Cache::factory();
|
||||||
$key = sprintf('Project:%s::IDF_Views_Source::treeBase:%s::',
|
$key = sprintf('Project:%s::IDF_Views_Source::treeBase:%s::',
|
||||||
$request->project->id, $commit);
|
$request->project->id, $commit);
|
||||||
@ -146,6 +152,8 @@ class IDF_Views_Source
|
|||||||
'commit' => $commit,
|
'commit' => $commit,
|
||||||
'tree_in' => $in_branches,
|
'tree_in' => $in_branches,
|
||||||
'branches' => $branches,
|
'branches' => $branches,
|
||||||
|
'tags' => $tags,
|
||||||
|
'tags_in' => $in_tags,
|
||||||
'props' => $props,
|
'props' => $props,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
@ -154,21 +162,18 @@ class IDF_Views_Source
|
|||||||
public $tree_precond = array('IDF_Precondition::accessSource');
|
public $tree_precond = array('IDF_Precondition::accessSource');
|
||||||
public function tree($request, $match)
|
public function tree($request, $match)
|
||||||
{
|
{
|
||||||
$title = sprintf(__('%1$s %2$s Source Tree'),
|
|
||||||
$request->project, $this->getScmType($request));
|
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
$commit = $match[2];
|
$commit = $match[2];
|
||||||
$request_file = $match[3];
|
|
||||||
|
|
||||||
if (!$scm->isAvailable()) {
|
if (!$scm->isAvailable()) {
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::help',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::help',
|
||||||
array($request->project->shortname));
|
array($request->project->shortname));
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
$branches = $scm->getBranches();
|
|
||||||
$fburl = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
$fburl = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
||||||
array($request->project->shortname,
|
array($request->project->shortname,
|
||||||
$scm->getMainBranch()));
|
$scm->getMainBranch()));
|
||||||
|
$request_file = $match[3];
|
||||||
if (substr($request_file, -1) == '/') {
|
if (substr($request_file, -1) == '/') {
|
||||||
$request_file = substr($request_file, 0, -1);
|
$request_file = substr($request_file, 0, -1);
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::tree',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::tree',
|
||||||
@ -185,11 +190,12 @@ class IDF_Views_Source
|
|||||||
// Redirect to the first branch
|
// Redirect to the first branch
|
||||||
return new Pluf_HTTP_Response_Redirect($fburl);
|
return new Pluf_HTTP_Response_Redirect($fburl);
|
||||||
}
|
}
|
||||||
|
$branches = $scm->getBranches();
|
||||||
|
$tags = $scm->getTags();
|
||||||
if ($request_file_info->type != 'tree') {
|
if ($request_file_info->type != 'tree') {
|
||||||
$info = self::getRequestedFileMimeType($request_file_info,
|
$info = self::getRequestedFileMimeType($request_file_info,
|
||||||
$commit, $scm);
|
$commit, $scm);
|
||||||
if (!self::isText($info)) {
|
if (!self::isText($info)) {
|
||||||
|
|
||||||
$rep = new Pluf_HTTP_Response($scm->getFile($request_file_info),
|
$rep = new Pluf_HTTP_Response($scm->getFile($request_file_info),
|
||||||
$info[0]);
|
$info[0]);
|
||||||
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$info[1].'"';
|
$rep->headers['Content-Disposition'] = 'attachment; filename="'.$info[1].'"';
|
||||||
@ -197,6 +203,7 @@ class IDF_Views_Source
|
|||||||
} else {
|
} else {
|
||||||
// We want to display the content of the file as text
|
// We want to display the content of the file as text
|
||||||
$extra = array('branches' => $branches,
|
$extra = array('branches' => $branches,
|
||||||
|
'tags' => $tags,
|
||||||
'commit' => $commit,
|
'commit' => $commit,
|
||||||
'request_file' => $request_file,
|
'request_file' => $request_file,
|
||||||
'request_file_info' => $request_file_info,
|
'request_file_info' => $request_file_info,
|
||||||
@ -207,6 +214,8 @@ class IDF_Views_Source
|
|||||||
}
|
}
|
||||||
|
|
||||||
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->fullpath);
|
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->fullpath);
|
||||||
|
$title = sprintf(__('%1$s %2$s Source Tree'),
|
||||||
|
$request->project, $this->getScmType($request));
|
||||||
|
|
||||||
$page_title = $bc.' - '.$title;
|
$page_title = $bc.' - '.$title;
|
||||||
$cobject = $scm->getCommit($commit);
|
$cobject = $scm->getCommit($commit);
|
||||||
@ -218,6 +227,7 @@ class IDF_Views_Source
|
|||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
$in_branches = $scm->inBranches($commit, $request_file);
|
$in_branches = $scm->inBranches($commit, $request_file);
|
||||||
|
$in_tags = $scm->inTags($commit, $request_file);
|
||||||
$cache = Pluf_Cache::factory();
|
$cache = Pluf_Cache::factory();
|
||||||
$key = sprintf('Project:%s::IDF_Views_Source::tree:%s::%s',
|
$key = sprintf('Project:%s::IDF_Views_Source::tree:%s::%s',
|
||||||
$request->project->id, $commit, $request_file);
|
$request->project->id, $commit, $request_file);
|
||||||
@ -243,6 +253,8 @@ class IDF_Views_Source
|
|||||||
'prev' => $previous,
|
'prev' => $previous,
|
||||||
'tree_in' => $in_branches,
|
'tree_in' => $in_branches,
|
||||||
'branches' => $branches,
|
'branches' => $branches,
|
||||||
|
'tags' => $tags,
|
||||||
|
'tags_in' => $in_tags,
|
||||||
'props' => $props,
|
'props' => $props,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
@ -270,7 +282,6 @@ class IDF_Views_Source
|
|||||||
{
|
{
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
$commit = $match[2];
|
$commit = $match[2];
|
||||||
$branches = $scm->getBranches();
|
|
||||||
if (!$scm->isValidRevision($commit)) {
|
if (!$scm->isValidRevision($commit)) {
|
||||||
// Redirect to the first branch
|
// Redirect to the first branch
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
||||||
@ -293,7 +304,10 @@ class IDF_Views_Source
|
|||||||
$diff = new IDF_Diff($cobject->changes);
|
$diff = new IDF_Diff($cobject->changes);
|
||||||
$diff->parse();
|
$diff->parse();
|
||||||
$scmConf = $request->conf->getVal('scm', 'git');
|
$scmConf = $request->conf->getVal('scm', 'git');
|
||||||
$in_branches = $scm->inBranches($commit, '');
|
$branches = $scm->getBranches();
|
||||||
|
$in_branches = $scm->inBranches($cobject->commit, '');
|
||||||
|
$tags = $scm->getTags();
|
||||||
|
$in_tags = $scm->inTags($cobject->commit, '');
|
||||||
return Pluf_Shortcuts_RenderToResponse('idf/source/commit.html',
|
return Pluf_Shortcuts_RenderToResponse('idf/source/commit.html',
|
||||||
array(
|
array(
|
||||||
'page_title' => $page_title,
|
'page_title' => $page_title,
|
||||||
@ -303,6 +317,8 @@ class IDF_Views_Source
|
|||||||
'commit' => $commit,
|
'commit' => $commit,
|
||||||
'branches' => $branches,
|
'branches' => $branches,
|
||||||
'tree_in' => $in_branches,
|
'tree_in' => $in_branches,
|
||||||
|
'tags' => $tags,
|
||||||
|
'tags_in' => $in_tags,
|
||||||
'scm' => $scmConf,
|
'scm' => $scmConf,
|
||||||
'rcommit' => $rcommit,
|
'rcommit' => $rcommit,
|
||||||
'large_commit' => $large,
|
'large_commit' => $large,
|
||||||
@ -315,7 +331,6 @@ class IDF_Views_Source
|
|||||||
{
|
{
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
$commit = $match[2];
|
$commit = $match[2];
|
||||||
$branches = $scm->getBranches();
|
|
||||||
if (!$scm->isValidRevision($commit)) {
|
if (!$scm->isValidRevision($commit)) {
|
||||||
// Redirect to the first branch
|
// Redirect to the first branch
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
||||||
@ -338,6 +353,7 @@ class IDF_Views_Source
|
|||||||
$this->getScmType($request));
|
$this->getScmType($request));
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
$branches = $extra['branches'];
|
$branches = $extra['branches'];
|
||||||
|
$tags = $extra['tags'];
|
||||||
$commit = $extra['commit'];
|
$commit = $extra['commit'];
|
||||||
$request_file = $extra['request_file'];
|
$request_file = $extra['request_file'];
|
||||||
$request_file_info = $extra['request_file_info'];
|
$request_file_info = $extra['request_file_info'];
|
||||||
@ -345,6 +361,7 @@ class IDF_Views_Source
|
|||||||
$page_title = $bc.' - '.$title;
|
$page_title = $bc.' - '.$title;
|
||||||
$cobject = $scm->getCommit($commit);
|
$cobject = $scm->getCommit($commit);
|
||||||
$in_branches = $scm->inBranches($commit, $request_file);
|
$in_branches = $scm->inBranches($commit, $request_file);
|
||||||
|
$in_tags = $scm->inTags($commit, '');
|
||||||
// try to find the previous level if it exists.
|
// try to find the previous level if it exists.
|
||||||
$prev = explode('/', $request_file);
|
$prev = explode('/', $request_file);
|
||||||
$l = array_pop($prev);
|
$l = array_pop($prev);
|
||||||
@ -365,6 +382,8 @@ class IDF_Views_Source
|
|||||||
'prev' => $previous,
|
'prev' => $previous,
|
||||||
'tree_in' => $in_branches,
|
'tree_in' => $in_branches,
|
||||||
'branches' => $branches,
|
'branches' => $branches,
|
||||||
|
'tags' => $tags,
|
||||||
|
'tags_in' => $in_tags,
|
||||||
'props' => $props,
|
'props' => $props,
|
||||||
),
|
),
|
||||||
$request);
|
$request);
|
||||||
@ -378,7 +397,6 @@ class IDF_Views_Source
|
|||||||
public function getFile($request, $match)
|
public function getFile($request, $match)
|
||||||
{
|
{
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
$branches = $scm->getBranches();
|
|
||||||
$commit = $match[2];
|
$commit = $match[2];
|
||||||
$request_file = $match[3];
|
$request_file = $match[3];
|
||||||
if (!$scm->isValidRevision($commit)) {
|
if (!$scm->isValidRevision($commit)) {
|
||||||
@ -413,7 +431,6 @@ class IDF_Views_Source
|
|||||||
{
|
{
|
||||||
$commit = trim($match[2]);
|
$commit = trim($match[2]);
|
||||||
$scm = IDF_Scm::get($request->project);
|
$scm = IDF_Scm::get($request->project);
|
||||||
$branches = $scm->getBranches();
|
|
||||||
if (!$scm->isValidRevision($commit)) {
|
if (!$scm->isValidRevision($commit)) {
|
||||||
// Redirect to the first branch
|
// Redirect to the first branch
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{extends "idf/base.html"}
|
{extends "idf/base.html"}
|
||||||
{block tabsource} class="active"{/block}
|
{block tabsource} class="active"{/block}
|
||||||
{block subtabs}
|
{block subtabs}
|
||||||
{if !$inHelp and array_key_exists($commit, $branches)}{assign $currentCommit = $commit}{else}{assign $currentCommit = $project.getScmRoot()}{/if}
|
{if !$inHelp and (in_array($commit, $tree_in) or (in_array($commit, $tags_in)))}{assign $currentCommit = $commit}{else}{assign $currentCommit = $project.getScmRoot()}{/if}
|
||||||
<div id="sub-tabs">
|
<div id="sub-tabs">
|
||||||
<a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $currentCommit)}">{trans 'Source Tree'}</a> |
|
<a {if $inSourceTree}class="active" {/if}href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $currentCommit)}">{trans 'Source Tree'}</a> |
|
||||||
<a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, $currentCommit)}">{trans 'Change Log'}</a>
|
<a {if $inChangeLog}class="active" {/if}href="{url 'IDF_Views_Source::changeLog', array($project.shortname, $currentCommit)}">{trans 'Change Log'}</a>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{extends "idf/source/base.html"}
|
{extends "idf/source/base.html"}
|
||||||
{block extraheader}<link rel="stylesheet" type="text/css" href="{media '/idf/css/prettify.css'}" />{/block}
|
{block extraheader}<link rel="stylesheet" type="text/css" href="{media '/idf/css/prettify.css'}"/>{/block}
|
||||||
{block docclass}yui-t1{assign $inCommit=true}{/block}
|
{block docclass}yui-t1{assign $inCommit=true}{/block}
|
||||||
{block body}
|
{block body}
|
||||||
<table class="commit" summary="">
|
<table class="commit" summary="">
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<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>
|
||||||
<th><strong>{trans 'Message:'}</strong></th><td>{issuetext $cobject.title, $request}{if isset($cobject.full_message)}<br /><br />{issuetext $cobject.full_message, $request, true, false, true, true, true}{/if}</td>
|
<th><strong>{trans 'Message:'}</strong></th><td>{issuetext $cobject.title, $request}{if isset($cobject.full_message)}<br/><br/>{issuetext $cobject.full_message, $request, true, false, true, true, true}{/if}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{if count($diff.files)}
|
{if count($diff.files)}
|
||||||
<tr>
|
<tr>
|
||||||
@ -21,7 +21,7 @@
|
|||||||
<td>
|
<td>
|
||||||
{foreach $diff.files as $filename=>$diffdef}
|
{foreach $diff.files as $filename=>$diffdef}
|
||||||
{assign $ndiff = count($diffdef['chunks'])}
|
{assign $ndiff = count($diffdef['chunks'])}
|
||||||
<a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $filename)}">{$filename}</a> (<a href="#diff-{$filename|md5}">{blocktrans $ndiff}{$ndiff} diff{plural}{$ndiff} diffs{/blocktrans}</a>)<br />
|
<a href="{url 'IDF_Views_Source::tree', array($project.shortname, $commit, $filename)}">{$filename}</a> (<a href="#diff-{$filename|md5}">{blocktrans $ndiff}{$ndiff} diff{plural}{$ndiff} diffs{/blocktrans}</a>)<br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -33,24 +33,32 @@
|
|||||||
{$diff.as_html()}
|
{$diff.as_html()}
|
||||||
{/if}{if count($diff.files) or $large_commit}
|
{/if}{if count($diff.files) or $large_commit}
|
||||||
{aurl 'url', 'IDF_Views_Source::downloadDiff', array($project.shortname, $commit)}
|
{aurl 'url', 'IDF_Views_Source::downloadDiff', array($project.shortname, $commit)}
|
||||||
<p class="right soft"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom" /></a> <a href="{$url}">{trans 'Download the corresponding diff file'}</a></p>
|
<p class="right soft"><a href="{$url}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/package-grey.png'}" alt="{trans 'Archive'}" align="bottom"/></a> <a href="{$url}">{trans 'Download the corresponding diff file'}</a></p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
{block context}
|
{block context}
|
||||||
{if $scm != 'svn'}
|
{if $scm != 'svn'}
|
||||||
<p><strong>{trans 'Branches:'}</strong><br />
|
<p><strong>{trans 'Branches:'}</strong><br/>
|
||||||
{foreach $branches as $branch => $path}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
||||||
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
|
{if $tags}
|
||||||
|
<p><strong>{trans 'Tags:'}</strong><br/>
|
||||||
|
{foreach $tags as $tag => $path}
|
||||||
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $tag)}
|
||||||
|
<span class="label{if in_array($tag, $tags_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$tag}{/if}</a></span><br/>
|
||||||
|
{/foreach}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
<form class="star" action="{url 'IDF_Views_Source_Svn::changelogRev', array($project.shortname)}" method="get">
|
<form class="star" action="{url 'IDF_Views_Source_Svn::changelogRev', array($project.shortname)}" method="get">
|
||||||
<p><strong>{trans 'Revision:'}</strong> {$commit}</p>
|
<p><strong>{trans 'Revision:'}</strong> {$commit}</p>
|
||||||
<p>
|
<p>
|
||||||
<input accesskey="4" type="text" value="{$commit}" name="rev" size="5" />
|
<input accesskey="4" type="text" value="{$commit}" name="rev" size="5"/>
|
||||||
<input type="submit" name="s" value="{trans 'Go to revision'}" />
|
<input type="submit" name="s" value="{trans 'Go to revision'}"/>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
{extends "idf/source/changelog.html"}
|
{extends "idf/source/changelog.html"}
|
||||||
{block context}
|
{block context}
|
||||||
<p><strong>{trans 'Branches:'}</strong><br />
|
<p><strong>{trans 'Branches:'}</strong><br/>
|
||||||
{foreach $branches as $branch => $path}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $branch)}
|
||||||
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br />
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
|
{if $tags}
|
||||||
|
<p><strong>{trans 'Tags:'}</strong><br/>
|
||||||
|
{foreach $tags as $tag => $path}
|
||||||
|
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $tag)}
|
||||||
|
<span class="label{if in_array($tag, $tags_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$tag}{/if}</a></span><br/>
|
||||||
|
{/foreach}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
|
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
|
||||||
|
|
||||||
<table class="code" summary=" ">
|
<table class="code" summary=" ">
|
||||||
{if !$tree_in}
|
{if !$tree_in and !$tags_in}
|
||||||
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
|
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr><th colspan="2">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
|
<tr><th colspan="2">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br/>
|
||||||
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
|
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
|
||||||
</th></tr>
|
</th></tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@ -22,12 +22,20 @@
|
|||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
{block context}
|
{block context}
|
||||||
<p><strong>{trans 'Branches:'}</strong><br />
|
<p><strong>{trans 'Branches:'}</strong><br/>
|
||||||
{foreach $branches as $branch => $path}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
||||||
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br />
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
|
{if $tags}
|
||||||
|
<p><strong>{trans 'Tags:'}</strong><br/>
|
||||||
|
{foreach $tags as $tag => $path}
|
||||||
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $tag)}
|
||||||
|
<span class="label{if in_array($tag, $tags_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$tag}{/if}</a></span><br/>
|
||||||
|
{/foreach}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block javascript}
|
{block javascript}
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
<th>{trans 'Message'}</th>
|
<th>{trans 'Message'}</th>
|
||||||
<th>{trans 'Size'}</th>
|
<th>{trans 'Size'}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>{if !$tree_in}
|
</thead>{if !$tree_in and !$tags_in}
|
||||||
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
|
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br />
|
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br/>
|
||||||
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
|
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
|
||||||
</th></tr>
|
</th></tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@ -52,10 +52,18 @@
|
|||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
{block context}
|
{block context}
|
||||||
<p><strong>{trans 'Branches:'}</strong><br />
|
<p><strong>{trans 'Branches:'}</strong><br/>
|
||||||
{foreach $branches as $branch => $path}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
||||||
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br />
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$branch}{/if}</a></span><br/>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
|
{if $tags}
|
||||||
|
<p><strong>{trans 'Tags:'}</strong><br/>
|
||||||
|
{foreach $tags as $tag => $path}
|
||||||
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $tag)}
|
||||||
|
<span class="label{if in_array($tag, $tags_in)} active{/if}"><a href="{$url}" class="label">{if $path}{$path}{else}{$tag}{/if}</a></span><br/>
|
||||||
|
{/foreach}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
Loading…
Reference in New Issue
Block a user