2
2
3
3
import java .security .SecureRandom ;
4
4
import java .util .ArrayList ;
5
+ import java .util .Collection ;
5
6
import java .util .List ;
6
7
import java .util .Map ;
7
8
import java .util .Optional ;
@@ -206,7 +207,7 @@ public List<Engagement> getAllEngagements() {
206
207
207
208
List <Project > projects = projectService .getProjectsByGroup (engagementRepositoryId , true );
208
209
209
- return projects .parallelStream ().map (project -> getEngagement (project , true ))
210
+ return projects .parallelStream ().map (project -> getEngagement (project , true , true ))
210
211
.filter (Optional ::isPresent ).map (Optional ::get ).collect (Collectors .toList ());
211
212
212
213
}
@@ -217,7 +218,7 @@ public Engagement getEngagement(String namespaceOrId, boolean includeStatus) {
217
218
Optional <Project > project = projectService .getProjectByIdOrPath (namespaceOrId );
218
219
219
220
if (project .isPresent ()) {
220
- engagement = getEngagement (project .get (), includeStatus ).orElse (null );
221
+ engagement = getEngagement (project .get (), includeStatus , true ).orElse (null );
221
222
}
222
223
223
224
return engagement ;
@@ -229,21 +230,23 @@ public Engagement getEngagement(String customerName, String engagementName, bool
229
230
Optional <Project > project = getProject (customerName , engagementName );
230
231
231
232
if (project .isPresent ()) {
232
- engagement = getEngagement (project .get (), includeStatus ).orElse (null );
233
+ engagement = getEngagement (project .get (), includeStatus , true ).orElse (null );
233
234
}
234
235
235
236
return engagement ;
236
237
}
237
238
238
- public Optional <Engagement > getEngagement (Project project , boolean includeStatus ) {
239
+ public Optional <Engagement > getEngagement (Project project , boolean includeStatus , boolean includeCommits ) {
239
240
Engagement engagement = null ;
240
241
241
242
Optional <File > engagementFile = fileService .getFileAllow404 (project .getId (), ENGAGEMENT_FILE );
242
243
if (engagementFile .isPresent ()) {
243
244
engagement = json .fromJson (engagementFile .get ().getContent (), Engagement .class );
244
245
245
- List <Commit > commits = projectService .getCommitLog (String .valueOf (engagement .getProjectId ()));
246
- engagement .setCommits (commits );
246
+ if (includeCommits ) {
247
+ List <Commit > commits = projectService .getCommitLog (String .valueOf (engagement .getProjectId ()));
248
+ engagement .setCommits (commits );
249
+ }
247
250
}
248
251
249
252
if (includeStatus && engagement != null ) {
@@ -307,7 +310,7 @@ private CommitMultiple createCommitMultiple(List<File> filesToCommit, Integer pr
307
310
.collect (Collectors .toList ());
308
311
309
312
// merge the actions
310
- List <Action > actions = Stream .of (userManagementFiles , otherFiles ).flatMap (x -> x . stream () )
313
+ List <Action > actions = Stream .of (userManagementFiles , otherFiles ).flatMap (Collection :: stream )
311
314
.collect (Collectors .toList ());
312
315
313
316
// use message if provided. otherwise, defaults
@@ -320,7 +323,7 @@ private CommitMultiple createCommitMultiple(List<File> filesToCommit, Integer pr
320
323
}
321
324
322
325
private Action createAction (File file , boolean isNew ) {
323
- FileAction action = isNew ? FileAction .CREATE : FileAction .UPDATE ;
326
+ FileAction action = isNew ? FileAction .create : FileAction .update ;
324
327
325
328
return Action .builder ().action (action ).filePath (stripPrefix (file .getFilePath ())).content (file .getContent ())
326
329
.encoding ("base64" ).build ();
0 commit comments