You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TagPage.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.wicket.pages;
  17. import java.util.List;
  18. import org.apache.wicket.PageParameters;
  19. import org.eclipse.jgit.lib.Repository;
  20. import org.eclipse.jgit.revwalk.RevCommit;
  21. import com.gitblit.utils.JGitUtils;
  22. import com.gitblit.utils.JGitUtils.SearchType;
  23. import com.gitblit.wicket.LinkPanel;
  24. import com.gitblit.wicket.RepositoryPage;
  25. import com.gitblit.wicket.WicketUtils;
  26. import com.gitblit.wicket.models.RefModel;
  27. public class TagPage extends RepositoryPage {
  28. public TagPage(PageParameters params) {
  29. super(params);
  30. Repository r = getRepository();
  31. RevCommit c = getCommit();
  32. List<RefModel> tags = JGitUtils.getTags(r, -1);
  33. RefModel tagRef = null;
  34. // determine tag
  35. for (RefModel tag : tags) {
  36. if (tag.getName().equals(objectId) || tag.getObjectId().getName().equals(objectId)) {
  37. tagRef = tag;
  38. break;
  39. }
  40. }
  41. if (tagRef == null) {
  42. // point to commit
  43. add(new LinkPanel("commit", "title", c.getShortMessage(), CommitPage.class, newCommitParameter()));
  44. add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class, newCommitParameter(c.getName())));
  45. } else {
  46. // TODO commit or tree or blob?
  47. add(new LinkPanel("commit", "title", tagRef.getDisplayName(), CommitPage.class, newCommitParameter()));
  48. add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class, newCommitParameter(c.getName())));
  49. }
  50. add(createPersonPanel("tagAuthor", c.getAuthorIdent(), SearchType.AUTHOR));
  51. add(WicketUtils.createTimestampLabel("tagDate", c.getAuthorIdent().getWhen(), getTimeZone()));
  52. addFullText("fullMessage", c.getFullMessage(), true);
  53. }
  54. @Override
  55. protected String getPageName() {
  56. return getString("gb.tag");
  57. }
  58. }