1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.api;
11
12 import java.util.List;
13 import java.util.Map;
14
15 import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
16 import org.eclipse.jgit.revwalk.RevCommit;
17
18
19
20
21 public class RebaseResult {
22
23
24
25 public enum Status {
26
27
28
29 OK {
30 @Override
31 public boolean isSuccessful() {
32 return true;
33 }
34 },
35
36
37
38 ABORTED {
39 @Override
40 public boolean isSuccessful() {
41 return false;
42 }
43 },
44
45
46
47 STOPPED {
48 @Override
49 public boolean isSuccessful() {
50 return false;
51 }
52 },
53
54
55
56
57
58 EDIT {
59 @Override
60 public boolean isSuccessful() {
61 return false;
62 }
63 },
64
65
66
67 FAILED {
68 @Override
69 public boolean isSuccessful() {
70 return false;
71 }
72 },
73
74
75
76
77
78
79 UNCOMMITTED_CHANGES {
80 @Override
81 public boolean isSuccessful() {
82 return false;
83 }
84 },
85
86
87
88 CONFLICTS {
89 @Override
90 public boolean isSuccessful() {
91 return false;
92 }
93 },
94
95
96
97 UP_TO_DATE {
98 @Override
99 public boolean isSuccessful() {
100 return true;
101 }
102 },
103
104
105
106 FAST_FORWARD {
107 @Override
108 public boolean isSuccessful() {
109 return true;
110 }
111 },
112
113
114
115
116
117
118 NOTHING_TO_COMMIT {
119 @Override
120 public boolean isSuccessful() {
121 return false;
122 }
123 },
124
125
126
127
128
129 INTERACTIVE_PREPARED {
130 @Override
131 public boolean isSuccessful() {
132 return false;
133 }
134 },
135
136
137
138
139
140
141 STASH_APPLY_CONFLICTS {
142 @Override
143 public boolean isSuccessful() {
144 return true;
145 }
146 };
147
148
149
150
151 public abstract boolean isSuccessful();
152 }
153
154 static final RebaseResultl#RebaseResult">RebaseResult OK_RESULT = new RebaseResult(Status.OK);
155
156 static final RebaseResultaseResult">RebaseResult ABORTED_RESULT = new RebaseResult(Status.ABORTED);
157
158 static final RebaseResultResult">RebaseResult UP_TO_DATE_RESULT = new RebaseResult(
159 Status.UP_TO_DATE);
160
161 static final RebaseResultsult">RebaseResult FAST_FORWARD_RESULT = new RebaseResult(
162 Status.FAST_FORWARD);
163
164 static final RebaseResult>RebaseResult NOTHING_TO_COMMIT_RESULT = new RebaseResult(
165 Status.NOTHING_TO_COMMIT);
166
167 static final RebaseResultaseResult INTERACTIVE_PREPARED_RESULT = new RebaseResult(
168 Status.INTERACTIVE_PREPARED);
169
170 static final RebaseResultaseResult STASH_APPLY_CONFLICTS_RESULT = new RebaseResult(
171 Status.STASH_APPLY_CONFLICTS);
172
173 private final Status status;
174
175 private final RevCommit currentCommit;
176
177 private Map<String, MergeFailureReason> failingPaths;
178
179 private List<String> conflicts;
180
181 private List<String> uncommittedChanges;
182
183 private RebaseResult(Status status) {
184 this.status = status;
185 currentCommit = null;
186 }
187
188 private RebaseResult(Status status, RevCommit commit) {
189 this.status = status;
190 currentCommit = commit;
191 }
192
193
194
195
196
197
198
199
200
201 static RebaseResult result(RebaseResult.Status status,
202 RevCommit commit) {
203 return new RebaseResult(status, commit);
204 }
205
206
207
208
209
210
211
212
213 static RebaseResult failed(
214 Map<String, MergeFailureReason> failingPaths) {
215 RebaseResult result = new RebaseResult(Status.FAILED);
216 result.failingPaths = failingPaths;
217 return result;
218 }
219
220
221
222
223
224
225
226
227 static RebaseResult conflicts(List<String> conflicts) {
228 RebaseResult result = new RebaseResult(Status.CONFLICTS);
229 result.conflicts = conflicts;
230 return result;
231 }
232
233
234
235
236
237
238
239
240
241 static RebaseResult uncommittedChanges(List<String> uncommittedChanges) {
242 RebaseResult result = new RebaseResult(Status.UNCOMMITTED_CHANGES);
243 result.uncommittedChanges = uncommittedChanges;
244 return result;
245 }
246
247
248
249
250
251
252 public Status getStatus() {
253 return status;
254 }
255
256
257
258
259
260
261
262
263
264
265 public RevCommit getCurrentCommit() {
266 return currentCommit;
267 }
268
269
270
271
272
273
274
275
276
277
278 public Map<String, MergeFailureReason> getFailingPaths() {
279 return failingPaths;
280 }
281
282
283
284
285
286
287
288 public List<String> getConflicts() {
289 return conflicts;
290 }
291
292
293
294
295
296
297
298
299 public List<String> getUncommittedChanges() {
300 return uncommittedChanges;
301 }
302
303 }