| | |
| | | import org.apache.wicket.markup.html.panel.Fragment;
|
| | | import org.apache.wicket.model.IModel;
|
| | | import org.apache.wicket.model.Model;
|
| | | import org.apache.wicket.protocol.http.RequestUtils;
|
| | | import org.apache.wicket.request.target.basic.RedirectRequestTarget;
|
| | | import org.eclipse.jgit.diff.DiffEntry.ChangeType;
|
| | | import org.eclipse.jgit.lib.PersonIdent;
|
| | |
| | | }
|
| | | pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
|
| | | pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
|
| | | pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
|
| | | pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));
|
| | | if (GitBlit.getBoolean(Keys.web.allowForking, true)) {
|
| | | pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true));
|
| | |
| | |
|
| | | // conditional links
|
| | | // per-repository extra page links
|
| | | if (model.useDocs) {
|
| | | pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));
|
| | | }
|
| | | if (JGitUtils.getPagesBranch(r) != null) {
|
| | | OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink(
|
| | | getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null), true);
|
| | |
| | | // indicate origin repository
|
| | | RepositoryModel model = getRepositoryModel();
|
| | | if (StringUtils.isEmpty(model.originRepository)) {
|
| | | add(new Label("originRepository").setVisible(false));
|
| | | if (model.isMirror) {
|
| | | Fragment mirrorFrag = new Fragment("originRepository", "mirrorFragment", this);
|
| | | Label lbl = new Label("originRepository", MessageFormat.format(getString("gb.mirrorOf"), "<b>" + model.origin + "</b>"));
|
| | | mirrorFrag.add(lbl.setEscapeModelStrings(false));
|
| | | add(mirrorFrag);
|
| | | } else {
|
| | | add(new Label("originRepository").setVisible(false));
|
| | | }
|
| | | } else {
|
| | | RepositoryModel origin = GitBlit.self().getRepositoryModel(model.originRepository);
|
| | | if (origin == null) {
|
| | |
| | | }
|
| | | getSubmodules(commit);
|
| | | return commit;
|
| | | }
|
| | |
|
| | | protected String getBestCommitId(RevCommit commit) {
|
| | | String head = null;
|
| | | try {
|
| | | head = r.resolve(getRepositoryModel().HEAD).getName();
|
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | String id = commit.getName();
|
| | | if (!StringUtils.isEmpty(head) && head.equals(id)) {
|
| | | // match default branch
|
| | | return Repository.shortenRefName(getRepositoryModel().HEAD);
|
| | | }
|
| | |
|
| | | // find first branch match
|
| | | for (RefModel ref : JGitUtils.getLocalBranches(r, false, -1)) {
|
| | | if (ref.getObjectId().getName().equals(id)) {
|
| | | return ref.getName();
|
| | | }
|
| | | }
|
| | |
|
| | | // return sha
|
| | | return id;
|
| | | }
|
| | |
|
| | | protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) {
|
| | |
| | | String searchString = searchBoxModel.getObject();
|
| | | if (StringUtils.isEmpty(searchString)) {
|
| | | // redirect to self to avoid wicket page update bug
|
| | | PageParameters params = RepositoryPage.this.getPageParameters();
|
| | | String relativeUrl = urlFor(RepositoryPage.this.getClass(), params).toString();
|
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
|
| | | String absoluteUrl = getCanonicalUrl();
|
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | return;
|
| | | }
|
| | |
| | | // use an absolute url to workaround Wicket-Tomcat problems with
|
| | | // mounted url parameters (issue-111)
|
| | | PageParameters params = WicketUtils.newSearchParameter(repositoryName, null, searchString, searchType);
|
| | | String relativeUrl = urlFor(searchPageClass, params).toString();
|
| | | String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
|
| | | String absoluteUrl = getCanonicalUrl(searchPageClass, params);
|
| | | getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
|
| | | }
|
| | | }
|