| | |
| | | import com.gitblit.PagesServlet;
|
| | | import com.gitblit.SyndicationServlet;
|
| | | import com.gitblit.models.ProjectModel;
|
| | | import com.gitblit.models.RefModel;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.SubmoduleModel;
|
| | | import com.gitblit.models.UserModel;
|
| | |
| | |
|
| | | if (!getRepositoryModel().hasCommits) {
|
| | | setResponsePage(EmptyRepositoryPage.class, params);
|
| | | }
|
| | | |
| | | if (getRepositoryModel().isCollectingGarbage) {
|
| | | error(MessageFormat.format(getString("gb.busyCollectingGarbage"), getRepositoryModel().name), true);
|
| | | }
|
| | |
|
| | | if (objectId != null) {
|
| | | RefModel branch = null;
|
| | | if ((branch = JGitUtils.getBranch(getRepository(), objectId)) != null) {
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | if (user == null) {
|
| | | // workaround until get().getUser() is reviewed throughout the app
|
| | | user = UserModel.ANONYMOUS;
|
| | | }
|
| | | boolean canAccess = user.hasBranchPermission(repositoryName,
|
| | | branch.reference.getName());
|
| | | if (!canAccess) {
|
| | | error(getString("gb.accessDeined"), true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // register the available page links for this page and user
|
| | |
| | | add(new Label("pageName", pageName).setRenderBodyOnly(true));
|
| | |
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | if (user == null) {
|
| | | user = UserModel.ANONYMOUS;
|
| | | }
|
| | |
|
| | | // indicate origin repository
|
| | | RepositoryModel model = getRepositoryModel();
|
| | |
| | | if (origin == null) {
|
| | | // no origin repository
|
| | | add(new Label("originRepository").setVisible(false));
|
| | | } else if (!user.canViewRepository(origin)) {
|
| | | } else if (!user.canView(origin)) {
|
| | | // show origin repository without link
|
| | | Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
|
| | | forkFrag.add(new Label("originRepository", StringUtils.stripDotGit(model.originRepository)));
|
| | |
| | | }
|
| | |
|
| | | // fork controls
|
| | | if (!allowForkControls() || user == null) {
|
| | | if (!allowForkControls() || user == null || !user.isAuthenticated) {
|
| | | // must be logged-in to fork, hide all fork controls
|
| | | add(new ExternalLink("forkLink", "").setVisible(false));
|
| | | add(new ExternalLink("myForkLink", "").setVisible(false));
|
| | |
| | | } else {
|
| | | String fork = GitBlit.self().getFork(user.username, model.name);
|
| | | boolean hasFork = fork != null;
|
| | | boolean canFork = user.canForkRepository(model);
|
| | | boolean canFork = user.canFork(model);
|
| | |
|
| | | if (hasFork || !canFork) {
|
| | | // user not allowed to fork or fork already exists or repo forbids forking
|
| | | add(new ExternalLink("forkLink", "").setVisible(false));
|
| | |
|
| | | if (user.canFork && !model.allowForks) {
|
| | | if (user.canFork() && !model.allowForks) {
|
| | | // show forks prohibited indicator
|
| | | Fragment wc = new Fragment("forksProhibitedIndicator", "forksProhibitedFragment", this);
|
| | | Label lbl = new Label("forksProhibited", getString("gb.forksProhibited"));
|
| | |
| | | }
|
| | |
|
| | | protected String getShortObjectId(String objectId) {
|
| | | return objectId.substring(0, 8);
|
| | | return objectId.substring(0, GitBlit.getInteger(Keys.web.shortCommitIdLength, 6));
|
| | | }
|
| | |
|
| | | protected void addRefs(Repository r, RevCommit c) {
|
| | |
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | }
|
| | | }
|
| | | } |
| | | } |