summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca@milanesio.org>2012-12-02 08:52:28 +0000
committerLuca Milanesio <luca@milanesio.org>2012-12-02 08:53:10 +0000
commit9da9764c5073118fc3b46bb360e1071426a9b9f4 (patch)
treeaf8e0d0b4f15b3bd2b82f510038c5fd50ba77f4e
parent13f880f5f959e2d4ae2304c9cf9760fc1de32f10 (diff)
downloadgitblit-9da9764c5073118fc3b46bb360e1071426a9b9f4.tar.gz
gitblit-9da9764c5073118fc3b46bb360e1071426a9b9f4.zip
Branch display filtering according to user access permissions.
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java
index cfe9f5fe..956e3494 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.java
@@ -36,8 +36,10 @@ import com.gitblit.GitBlit;
import com.gitblit.SyndicationServlet;
import com.gitblit.models.RefModel;
import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.UserModel;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.BranchesPage;
import com.gitblit.wicket.pages.CommitPage;
@@ -58,9 +60,21 @@ public class BranchesPanel extends BasePanel {
// branches
List<RefModel> branches = new ArrayList<RefModel>();
- branches.addAll(JGitUtils.getLocalBranches(r, false, maxCount));
+ UserModel user = GitBlitWebSession.get().getUser();
+
+ List<RefModel> localBranches = JGitUtils.getLocalBranches(r, false, maxCount);
+ for (RefModel refModel : localBranches) {
+ if (user.hasBranchPermission(model.name, refModel.reference.getName())) {
+ branches.add(refModel);
+ }
+ }
if (model.showRemoteBranches) {
- branches.addAll(JGitUtils.getRemoteBranches(r, false, maxCount));
+ List<RefModel> remoteBranches = JGitUtils.getRemoteBranches(r, false, maxCount);
+ for (RefModel refModel : remoteBranches) {
+ if (user.hasBranchPermission(model.name, refModel.reference.getName())) {
+ branches.add(refModel);
+ }
+ }
}
Collections.sort(branches);
Collections.reverse(branches);