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.

RefModel.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.models;
  17. import java.io.Serializable;
  18. import java.util.Date;
  19. import org.eclipse.jgit.lib.ObjectId;
  20. import org.eclipse.jgit.lib.Ref;
  21. import org.eclipse.jgit.revwalk.RevCommit;
  22. import com.gitblit.utils.JGitUtils;
  23. public class RefModel implements Serializable, Comparable<RefModel> {
  24. private static final long serialVersionUID = 1L;
  25. final String displayName;
  26. transient Ref ref;
  27. final RevCommit commit;
  28. public RefModel(String displayName, Ref ref, RevCommit commit) {
  29. this.displayName = displayName;
  30. this.ref = ref;
  31. this.commit = commit;
  32. }
  33. public Date getDate() {
  34. return JGitUtils.getCommitDate(commit);
  35. }
  36. public String getDisplayName() {
  37. return displayName;
  38. }
  39. public String getName() {
  40. return ref.getName();
  41. }
  42. public RevCommit getCommit() {
  43. return commit;
  44. }
  45. public ObjectId getCommitId() {
  46. return commit.getId();
  47. }
  48. public String getShortLog() {
  49. return commit.getShortMessage();
  50. }
  51. public ObjectId getObjectId() {
  52. return ref.getObjectId();
  53. }
  54. public boolean isAnnotatedTag() {
  55. // ref.isPeeled() ??
  56. return !getCommitId().equals(getObjectId());
  57. }
  58. @Override
  59. public int compareTo(RefModel o) {
  60. return getDate().compareTo(o.getDate());
  61. }
  62. }