Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

RebaseResult.java 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
  3. * and other copyright owners as documented in the project's IP log.
  4. *
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Distribution License v1.0 which
  7. * accompanies this distribution, is reproduced below, and is
  8. * available at http://www.eclipse.org/org/documents/edl-v10.php
  9. *
  10. * All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials provided
  22. * with the distribution.
  23. *
  24. * - Neither the name of the Eclipse Foundation, Inc. nor the
  25. * names of its contributors may be used to endorse or promote
  26. * products derived from this software without specific prior
  27. * written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  30. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  31. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  34. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  36. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  38. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  41. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42. */
  43. package org.eclipse.jgit.api;
  44. import java.util.Map;
  45. import org.eclipse.jgit.merge.ResolveMerger;
  46. import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
  47. import org.eclipse.jgit.revwalk.RevCommit;
  48. /**
  49. * The result of a {@link RebaseCommand} execution
  50. */
  51. public class RebaseResult {
  52. /**
  53. * The overall status
  54. */
  55. public enum Status {
  56. /**
  57. * Rebase was successful, HEAD points to the new commit
  58. */
  59. OK {
  60. @Override
  61. public boolean isSuccessful() {
  62. return true;
  63. }
  64. },
  65. /**
  66. * Aborted; the original HEAD was restored
  67. */
  68. ABORTED {
  69. @Override
  70. public boolean isSuccessful() {
  71. return false;
  72. }
  73. },
  74. /**
  75. * Stopped due to a conflict; must either abort or resolve or skip
  76. */
  77. STOPPED {
  78. @Override
  79. public boolean isSuccessful() {
  80. return false;
  81. }
  82. },
  83. /**
  84. * Failed; the original HEAD was restored
  85. */
  86. FAILED {
  87. @Override
  88. public boolean isSuccessful() {
  89. return false;
  90. }
  91. },
  92. /**
  93. * Already up-to-date
  94. */
  95. UP_TO_DATE {
  96. @Override
  97. public boolean isSuccessful() {
  98. return true;
  99. }
  100. },
  101. /**
  102. * Fast-forward, HEAD points to the new commit
  103. */
  104. FAST_FORWARD {
  105. @Override
  106. public boolean isSuccessful() {
  107. return true;
  108. }
  109. },
  110. /**
  111. * Continue with nothing left to commit (possibly want skip).
  112. *
  113. * @since 2.0
  114. */
  115. NOTHING_TO_COMMIT {
  116. @Override
  117. public boolean isSuccessful() {
  118. return false;
  119. }
  120. };
  121. /**
  122. * @return whether the status indicates a successful result
  123. */
  124. public abstract boolean isSuccessful();
  125. }
  126. static final RebaseResult OK_RESULT = new RebaseResult(Status.OK);
  127. static final RebaseResult ABORTED_RESULT = new RebaseResult(Status.ABORTED);
  128. static final RebaseResult UP_TO_DATE_RESULT = new RebaseResult(
  129. Status.UP_TO_DATE);
  130. static final RebaseResult FAST_FORWARD_RESULT = new RebaseResult(
  131. Status.FAST_FORWARD);
  132. static final RebaseResult NOTHING_TO_COMMIT_RESULT = new RebaseResult(
  133. Status.NOTHING_TO_COMMIT);
  134. private final Status status;
  135. private final RevCommit currentCommit;
  136. private Map<String, MergeFailureReason> failingPaths;
  137. private RebaseResult(Status status) {
  138. this.status = status;
  139. currentCommit = null;
  140. }
  141. /**
  142. * Create <code>RebaseResult</code> with status {@link Status#STOPPED}
  143. *
  144. * @param commit
  145. * current commit
  146. */
  147. RebaseResult(RevCommit commit) {
  148. status = Status.STOPPED;
  149. currentCommit = commit;
  150. }
  151. /**
  152. * Create <code>RebaseResult</code> with status {@link Status#FAILED}
  153. *
  154. * @param failingPaths
  155. * list of paths causing this rebase to fail
  156. */
  157. RebaseResult(Map<String, MergeFailureReason> failingPaths) {
  158. status = Status.FAILED;
  159. currentCommit = null;
  160. this.failingPaths = failingPaths;
  161. }
  162. /**
  163. * @return the overall status
  164. */
  165. public Status getStatus() {
  166. return status;
  167. }
  168. /**
  169. * @return the current commit if status is {@link Status#STOPPED}, otherwise
  170. * <code>null</code>
  171. */
  172. public RevCommit getCurrentCommit() {
  173. return currentCommit;
  174. }
  175. /**
  176. * @return the list of paths causing this rebase to fail (see
  177. * {@link ResolveMerger#getFailingPaths()} for details) if status is
  178. * {@link Status#FAILED}, otherwise <code>null</code>
  179. */
  180. public Map<String, MergeFailureReason> getFailingPaths() {
  181. return failingPaths;
  182. }
  183. }