15
15
*/
16
16
package org .springframework .data .release .git ;
17
17
18
+ import lombok .RequiredArgsConstructor ;
19
+
18
20
import java .io .File ;
19
21
import java .io .IOException ;
20
22
import java .util .ArrayList ;
21
23
import java .util .List ;
22
24
import java .util .concurrent .Future ;
23
25
24
- import lombok .RequiredArgsConstructor ;
25
-
26
26
import org .springframework .beans .factory .annotation .Autowired ;
27
27
import org .springframework .core .env .Environment ;
28
28
import org .springframework .data .release .io .CommandResult ;
37
37
import org .springframework .data .release .model .Project ;
38
38
import org .springframework .data .release .model .Train ;
39
39
import org .springframework .data .release .model .TrainIteration ;
40
+ import org .springframework .data .release .utils .CommandUtils ;
40
41
import org .springframework .data .release .utils .Logger ;
41
42
import org .springframework .plugin .core .PluginRegistry ;
42
43
import org .springframework .stereotype .Component ;
49
50
* @author Oliver Gierke
50
51
*/
51
52
@ Component
52
- @ RequiredArgsConstructor (onConstructor = @ __ (@ Autowired ))
53
+ @ RequiredArgsConstructor (onConstructor = @ __ (@ Autowired ) )
53
54
public class GitOperations {
54
55
55
56
private final GitServer server = new GitServer ();
@@ -77,7 +78,8 @@ public void reset(TrainIteration train) throws Exception {
77
78
78
79
Branch branch = Branch .from (module );
79
80
80
- os .executeCommand (String .format ("git reset --hard origin/%s" , branch ), module .getProject ()).get ();
81
+ CommandUtils .getCommandResult (
82
+ os .executeCommand (String .format ("git reset --hard origin/%s" , branch ), module .getProject ()));
81
83
}
82
84
}
83
85
@@ -100,11 +102,11 @@ public void checkout(TrainIteration iteration) throws Exception {
100
102
Tag tag = findTagFor (project , artifactVersion );
101
103
102
104
if (tag == null ) {
103
- throw new IllegalStateException (String . format ( "No tag found for version %s of project %s, aborting." ,
104
- artifactVersion , project ));
105
+ throw new IllegalStateException (
106
+ String . format ( "No tag found for version %s of project %s, aborting." , artifactVersion , project ));
105
107
}
106
108
107
- os .executeCommand (String .format ("git checkout %s" , tag ), project ). get ( );
109
+ CommandUtils . getCommandResult ( os .executeCommand (String .format ("git checkout %s" , tag ), project ));
108
110
}
109
111
110
112
logger .log (iteration , "Successfully checked out projects." );
@@ -116,10 +118,10 @@ public void prepare(TrainIteration iteration) throws Exception {
116
118
117
119
Branch branch = Branch .from (module );
118
120
119
- update (module .getProject ()). get ( );
121
+ CommandUtils . getCommandResult ( update (module .getProject ()));
120
122
121
123
String checkoutCommand = String .format ("git checkout %s && git pull origin %s" , branch , branch );
122
- os .executeCommand (checkoutCommand , module .getProject ()). get ( );
124
+ CommandUtils . getCommandResult ( os .executeCommand (checkoutCommand , module .getProject ()));
123
125
}
124
126
}
125
127
@@ -132,7 +134,7 @@ public void update(Train train) throws Exception {
132
134
}
133
135
134
136
for (Future <CommandResult > execution : executions ) {
135
- execution . get ( );
137
+ CommandUtils . getCommandResult ( execution );
136
138
}
137
139
}
138
140
@@ -141,14 +143,15 @@ public void push(TrainIteration iteration) throws Exception {
141
143
for (ModuleIteration module : iteration ) {
142
144
143
145
Branch branch = Branch .from (module );
144
- os .executeCommand (String .format ("git push origin %s" , branch ), module .getProject ()).get ();
146
+ CommandUtils
147
+ .getCommandResult (os .executeCommand (String .format ("git push origin %s" , branch ), module .getProject ()));
145
148
}
146
149
}
147
150
148
151
public void pushTags (Train train ) throws Exception {
149
152
150
153
for (Module module : train ) {
151
- os .executeCommand ("git push --tags" , module .getProject ()). get ( );
154
+ CommandUtils . getCommandResult ( os .executeCommand ("git push --tags" , module .getProject ()));
152
155
}
153
156
}
154
157
@@ -198,15 +201,15 @@ public void tagRelease(TrainIteration iteration) throws Exception {
198
201
Project project = module .getProject ();
199
202
200
203
String checkoutCommand = String .format ("git checkout %s" , branch );
201
- os .executeCommand (checkoutCommand , project ). get ( );
204
+ CommandUtils . getCommandResult ( os .executeCommand (checkoutCommand , project ));
202
205
203
206
String updateCommand = String .format ("git pull origin %s" , branch );
204
- os .executeCommand (updateCommand , project ). get ( );
207
+ CommandUtils . getCommandResult ( os .executeCommand (updateCommand , project ));
205
208
206
209
String hash = getReleaseHash (module );
207
210
Tag tag = getTags (project ).createTag (module );
208
211
String tagCommand = String .format ("git tag %s %s" , tag , hash );
209
- os .executeCommand (tagCommand , project ). get ( );
212
+ CommandUtils . getCommandResult ( os .executeCommand (tagCommand , project ));
210
213
}
211
214
}
212
215
@@ -263,9 +266,9 @@ public void commit(ModuleIteration module, String summary, String details, File.
263
266
os .executeCommand (String .format ("git add %s" , file .getAbsolutePath ()), project ).get ();
264
267
}
265
268
266
- os .executeCommand (commitCommand , project ). get ( );
269
+ CommandUtils . getCommandResult ( os .executeCommand (commitCommand , project ));
267
270
} else {
268
- os .executeCommand (commitCommand .concat (" -a" ), project ). get ( );
271
+ CommandUtils . getCommandResult ( os .executeCommand (commitCommand .concat (" -a" ), project ));
269
272
}
270
273
}
271
274
@@ -288,8 +291,8 @@ private String getReleaseHash(ModuleIteration module) throws Exception {
288
291
}
289
292
}
290
293
291
- throw new IllegalStateException (String . format ( "Did not find a release commit for project %s (ticket id %s)" ,
292
- project , releaseTicket .getId ()));
294
+ throw new IllegalStateException (
295
+ String . format ( "Did not find a release commit for project %s (ticket id %s)" , project , releaseTicket .getId ()));
293
296
}
294
297
295
298
/**
0 commit comments