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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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,
  44. newCommitParameter()));
  45. add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class,
  46. newCommitParameter(c.getName())));
  47. } else {
  48. // TODO commit or tree or blob?
  49. add(new LinkPanel("commit", "title", tagRef.displayName, CommitPage.class,
  50. newCommitParameter()));
  51. add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class,
  52. newCommitParameter(c.getName())));
  53. }
  54. add(createPersonPanel("tagAuthor", c.getAuthorIdent(), SearchType.AUTHOR));
  55. add(WicketUtils
  56. .createTimestampLabel("tagDate", c.getAuthorIdent().getWhen(), getTimeZone()));
  57. addFullText("fullMessage", c.getFullMessage(), true);
  58. }
  59. @Override
  60. protected String getPageName() {
  61. return getString("gb.tag");
  62. }
  63. }