From c0dfd6b5dca56ad470ac8f38b5a927a9fe1e5098 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Wed, 8 Jul 2009 13:49:16 +0200 Subject: [PATCH] Fixed issue 180, can't select branches containing / character in git projects. --- src/IDF/Scm/Git.php | 7 ++++++- src/IDF/Views/Source.php | 2 +- src/IDF/templates/idf/source/changelog.html | 20 ------------------- .../templates/idf/source/git/changelog.html | 10 ++++++++++ src/IDF/templates/idf/source/git/file.html | 2 +- src/IDF/templates/idf/source/git/tree.html | 2 +- .../idf/source/mercurial/changelog.html | 10 ++++++++++ .../templates/idf/source/svn/changelog.html | 11 ++++++++++ 8 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 src/IDF/templates/idf/source/git/changelog.html create mode 100644 src/IDF/templates/idf/source/mercurial/changelog.html create mode 100644 src/IDF/templates/idf/source/svn/changelog.html diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index acb57ed..9824644 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -75,7 +75,12 @@ class IDF_Scm_Git extends IDF_Scm } $res = array(); foreach ($out as $b) { - $res[substr($b, 2)] = ''; + $b = substr($b, 2); + if (false !== strpos($b, '/')) { + $res[$this->getCommit($b)->commit] = $b; + } else { + $res[$b] = ''; + } } $this->cache['branches'] = $res; return $res; diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index 334ffe8..2f0d5c7 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -94,7 +94,7 @@ class IDF_Views_Source $rchanges = new Pluf_Template_ContextVars($rchanges); $scmConf = $request->conf->getVal('scm', 'git'); $in_branches = $scm->inBranches($commit, ''); - return Pluf_Shortcuts_RenderToResponse('idf/source/changelog.html', + return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/changelog.html', array( 'page_title' => $title, 'title' => $title, diff --git a/src/IDF/templates/idf/source/changelog.html b/src/IDF/templates/idf/source/changelog.html index 4a9a77e..971d3ba 100644 --- a/src/IDF/templates/idf/source/changelog.html +++ b/src/IDF/templates/idf/source/changelog.html @@ -27,23 +27,3 @@ {/block} - -{block context} -{if $scm != 'svn'} -

{trans 'Branches:'}
-{foreach $branches as $branch => $path} -{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} -{$branch}
-{/foreach} -

-{else} -
-

{trans 'Revision:'} {$commit}

-

- - -

-
-{/if} -{/block} - diff --git a/src/IDF/templates/idf/source/git/changelog.html b/src/IDF/templates/idf/source/git/changelog.html new file mode 100644 index 0000000..8c3ceb9 --- /dev/null +++ b/src/IDF/templates/idf/source/git/changelog.html @@ -0,0 +1,10 @@ +{extends "idf/source/changelog.html"} +{block context} +

{trans 'Branches:'}
+{foreach $branches as $branch => $path} +{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} +{if $path}{$path}{else}{$branch}{/if}
+{/foreach} +

+{/block} + diff --git a/src/IDF/templates/idf/source/git/file.html b/src/IDF/templates/idf/source/git/file.html index d2343bf..76e9b75 100644 --- a/src/IDF/templates/idf/source/git/file.html +++ b/src/IDF/templates/idf/source/git/file.html @@ -25,7 +25,7 @@

{trans 'Branches:'}
{foreach $branches as $branch => $path} {aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} -{$branch}
+{if $path}{$path}{else}{$branch}{/if}
{/foreach}

{/block} diff --git a/src/IDF/templates/idf/source/git/tree.html b/src/IDF/templates/idf/source/git/tree.html index b97db05..8bc8a68 100644 --- a/src/IDF/templates/idf/source/git/tree.html +++ b/src/IDF/templates/idf/source/git/tree.html @@ -55,7 +55,7 @@

{trans 'Branches:'}
{foreach $branches as $branch => $path} {aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} -{$branch}
+{if $path}{$path}{else}{$branch}{/if}
{/foreach}

{/block} diff --git a/src/IDF/templates/idf/source/mercurial/changelog.html b/src/IDF/templates/idf/source/mercurial/changelog.html new file mode 100644 index 0000000..6557c89 --- /dev/null +++ b/src/IDF/templates/idf/source/mercurial/changelog.html @@ -0,0 +1,10 @@ +{extends "idf/source/changelog.html"} +{block context} +

{trans 'Branches:'}
+{foreach $branches as $branch => $path} +{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)} +{$branch}
+{/foreach} +

+{/block} + diff --git a/src/IDF/templates/idf/source/svn/changelog.html b/src/IDF/templates/idf/source/svn/changelog.html new file mode 100644 index 0000000..b535e5c --- /dev/null +++ b/src/IDF/templates/idf/source/svn/changelog.html @@ -0,0 +1,11 @@ +{extends "idf/source/changelog.html"} +{block context} +
+

{trans 'Revision:'} {$commit}

+

+ + +

+
+{/block} +