1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.api;
11
12 import org.eclipse.jgit.transport.FetchResult;
13
14
15
16
17 public class PullResult {
18 private final FetchResult fetchResult;
19
20 private final MergeResult mergeResult;
21
22 private final RebaseResult rebaseResult;
23
24 private final String fetchedFrom;
25
26 PullResult(FetchResult fetchResult, String fetchedFrom,
27 MergeResult mergeResult) {
28 this.fetchResult = fetchResult;
29 this.fetchedFrom = fetchedFrom;
30 this.mergeResult = mergeResult;
31 this.rebaseResult = null;
32 }
33
34 PullResult(FetchResult fetchResult, String fetchedFrom,
35 RebaseResult rebaseResult) {
36 this.fetchResult = fetchResult;
37 this.fetchedFrom = fetchedFrom;
38 this.mergeResult = null;
39 this.rebaseResult = rebaseResult;
40 }
41
42
43
44
45
46
47 public FetchResult getFetchResult() {
48 return this.fetchResult;
49 }
50
51
52
53
54
55
56 public MergeResult getMergeResult() {
57 return this.mergeResult;
58 }
59
60
61
62
63
64
65 public RebaseResult getRebaseResult() {
66 return this.rebaseResult;
67 }
68
69
70
71
72
73
74
75 public String getFetchedFrom() {
76 return this.fetchedFrom;
77 }
78
79
80
81
82
83
84 public boolean isSuccessful() {
85 if (mergeResult != null)
86 return mergeResult.getMergeStatus().isSuccessful();
87 else if (rebaseResult != null)
88 return rebaseResult.getStatus().isSuccessful();
89 return true;
90 }
91
92
93 @SuppressWarnings("nls")
94 @Override
95 public String toString() {
96 StringBuilder sb = new StringBuilder();
97 if (fetchResult != null)
98 sb.append(fetchResult.toString());
99 else
100 sb.append("No fetch result");
101 sb.append("\n");
102 if (mergeResult != null)
103 sb.append(mergeResult.toString());
104 else if (rebaseResult != null)
105 sb.append(rebaseResult.toString());
106 else
107 sb.append("No update result");
108 return sb.toString();
109 }
110 }