]> source.dussan.org Git - gitblit.git/commitdiff
Branch display filtering according to user access permissions. 54/head
authorLuca Milanesio <luca@milanesio.org>
Sun, 2 Dec 2012 08:52:28 +0000 (08:52 +0000)
committerLuca Milanesio <luca@milanesio.org>
Sun, 2 Dec 2012 08:53:10 +0000 (08:53 +0000)
src/com/gitblit/wicket/panels/BranchesPanel.java

index cfe9f5fe5f4ae481637898893b36367993620e9b..956e3494edd6343c5f4d8df99573e9406b783d56 100644 (file)
@@ -36,8 +36,10 @@ import com.gitblit.GitBlit;
 import com.gitblit.SyndicationServlet;\r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.GitBlitWebSession;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.BranchesPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
@@ -58,9 +60,21 @@ public class BranchesPanel extends BasePanel {
 \r
                // branches\r
                List<RefModel> branches = new ArrayList<RefModel>();\r
-               branches.addAll(JGitUtils.getLocalBranches(r, false, maxCount));\r
+               UserModel user = GitBlitWebSession.get().getUser();\r
+\r
+               List<RefModel> localBranches = JGitUtils.getLocalBranches(r, false, maxCount);\r
+               for (RefModel refModel : localBranches) {\r
+                       if (user.hasBranchPermission(model.name, refModel.reference.getName())) {\r
+                               branches.add(refModel);\r
+                       }\r
+               }\r
                if (model.showRemoteBranches) {\r
-                       branches.addAll(JGitUtils.getRemoteBranches(r, false, maxCount));\r
+                       List<RefModel> remoteBranches = JGitUtils.getRemoteBranches(r, false, maxCount);\r
+                       for (RefModel refModel : remoteBranches) {\r
+                               if (user.hasBranchPermission(model.name, refModel.reference.getName())) {\r
+                                       branches.add(refModel);\r
+                               }\r
+                       }\r
                }\r
                Collections.sort(branches);\r
                Collections.reverse(branches);\r