Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.api;
  11. import org.eclipse.jgit.transport.FetchResult;
  12. /**
  13. * Encapsulates the result of a {@link org.eclipse.jgit.api.PullCommand}
  14. */
  15. public class PullResult {
  16. private final FetchResult fetchResult;
  17. private final MergeResult mergeResult;
  18. private final RebaseResult rebaseResult;
  19. private final String fetchedFrom;
  20. PullResult(FetchResult fetchResult, String fetchedFrom,
  21. MergeResult mergeResult) {
  22. this.fetchResult = fetchResult;
  23. this.fetchedFrom = fetchedFrom;
  24. this.mergeResult = mergeResult;
  25. this.rebaseResult = null;
  26. }
  27. PullResult(FetchResult fetchResult, String fetchedFrom,
  28. RebaseResult rebaseResult) {
  29. this.fetchResult = fetchResult;
  30. this.fetchedFrom = fetchedFrom;
  31. this.mergeResult = null;
  32. this.rebaseResult = rebaseResult;
  33. }
  34. /**
  35. * Get fetch result
  36. *
  37. * @return the fetch result, or <code>null</code>
  38. */
  39. public FetchResult getFetchResult() {
  40. return this.fetchResult;
  41. }
  42. /**
  43. * Get merge result
  44. *
  45. * @return the merge result, or <code>null</code>
  46. */
  47. public MergeResult getMergeResult() {
  48. return this.mergeResult;
  49. }
  50. /**
  51. * Get rebase result
  52. *
  53. * @return the rebase result, or <code>null</code>
  54. */
  55. public RebaseResult getRebaseResult() {
  56. return this.rebaseResult;
  57. }
  58. /**
  59. * Get name of the remote configuration from which fetch was tried
  60. *
  61. * @return the name of the remote configuration from which fetch was tried,
  62. * or <code>null</code>
  63. */
  64. public String getFetchedFrom() {
  65. return this.fetchedFrom;
  66. }
  67. /**
  68. * Whether the pull was successful
  69. *
  70. * @return whether the pull was successful
  71. */
  72. public boolean isSuccessful() {
  73. if (mergeResult != null)
  74. return mergeResult.getMergeStatus().isSuccessful();
  75. else if (rebaseResult != null)
  76. return rebaseResult.getStatus().isSuccessful();
  77. return true;
  78. }
  79. /** {@inheritDoc} */
  80. @SuppressWarnings("nls")
  81. @Override
  82. public String toString() {
  83. StringBuilder sb = new StringBuilder();
  84. if (fetchResult != null)
  85. sb.append(fetchResult.toString());
  86. else
  87. sb.append("No fetch result");
  88. sb.append("\n");
  89. if (mergeResult != null)
  90. sb.append(mergeResult.toString());
  91. else if (rebaseResult != null)
  92. sb.append(rebaseResult.toString());
  93. else
  94. sb.append("No update result");
  95. return sb.toString();
  96. }
  97. }