| | |
| | | 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.canView(getRepositoryModel(),
|
| | | branch.reference.getName());
|
| | | if (!canAccess) {
|
| | | error(getString("gb.accessDenied"), true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // register the available page links for this page and user
|
| | | registeredPages = registerPages();
|
| | |
| | | pages.put("branches", new PageRegistration("gb.branches", BranchesPage.class, params));
|
| | | pages.put("tags", new PageRegistration("gb.tags", TagsPage.class, params));
|
| | | pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
|
| | | pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params));
|
| | | if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
|
| | | pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params));
|
| | | }
|
| | |
|
| | | // conditional links
|
| | | Repository r = getRepository();
|
| | |
| | | }
|
| | |
|
| | | protected boolean allowForkControls() {
|
| | | return true;
|
| | | return GitBlit.getBoolean(Keys.web.allowForking, true);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | 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"));
|
| | |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel(
|
| | | GitBlitWebSession.get().getUser(), repositoryName);
|
| | | if (model == null) {
|
| | | if (GitBlit.self().hasRepository(repositoryName)) {
|
| | | if (GitBlit.self().hasRepository(repositoryName, true)) {
|
| | | // has repository, but unauthorized
|
| | | authenticationError(getString("gb.unauthorizedAccessForRepository") + " " + repositoryName);
|
| | | } else {
|
| | |
| | | }
|
| | |
|
| | | 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) {
|
| | |
| | | Constants.SearchType searchType) {
|
| | | String name = identity == null ? "" : identity.getName();
|
| | | String address = identity == null ? "" : identity.getEmailAddress();
|
| | | name = StringUtils.removeNewlines(name);
|
| | | address = StringUtils.removeNewlines(address);
|
| | | boolean showEmail = GitBlit.getBoolean(Keys.web.showEmailAddresses, false);
|
| | | if (!showEmail || StringUtils.isEmpty(name) || StringUtils.isEmpty(address)) {
|
| | | String value = name;
|
| | |
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | }
|
| | | }
|
| | | } |
| | | }
|