@@ -87,13 +87,16 @@ public Project createEngagement(Engagement engagement, String author, String aut
87
87
Project project = createProjectStucture (engagement );
88
88
engagement .setProjectId (project .getId ());
89
89
90
+ // get commit message before creating file
91
+ Optional <String > commitMessageOptional = Optional .ofNullable (engagement .getCommitMessage ());
92
+
90
93
// get all template files
91
94
List <File > repoFiles = new ArrayList <>();
92
95
repoFiles .add (createEngagmentFile (engagement ));
93
96
94
97
// create actions for multiple commit
95
98
CommitMultiple commit = createCommitMultiple (repoFiles , project .getId (), DEFAULT_BRANCH , author ,
96
- authorEmail , project .isFirst ());
99
+ authorEmail , project .isFirst (), commitMessageOptional );
97
100
98
101
if (LOGGER .isDebugEnabled ()) {
99
102
commit .getActions ().stream ().forEach (file -> LOGGER .debug ("Action File path :: {}" , file .getFilePath ()));
@@ -312,15 +315,17 @@ private Project getOrCreateProject(Integer namespaceId, String projectName, Proj
312
315
}
313
316
314
317
private CommitMultiple createCommitMultiple (List <File > filesToCommit , Integer projectId , String branch ,
315
- String authorName , String authorEmail , boolean isNew ) {
318
+ String authorName , String authorEmail , boolean isNew , Optional < String > commitMessageOptional ) {
316
319
317
320
List <Action > actions = new ArrayList <>();
318
321
319
322
// convert each file to action - parallelStream was bringing inconsistent
320
323
// results
321
324
filesToCommit .stream ().forEach (file -> actions .add (createAction (file , isNew )));
322
-
323
- String commitMessage = isNew ? commitMessage ("Engagement created" ) : commitMessage ("Engagement updated" );
325
+
326
+ // use message if provided. otherwise, defaults
327
+ String commitMessage = commitMessageOptional
328
+ .orElse (isNew ? commitMessage ("Engagement created" ) : commitMessage ("Engagement updated" ));
324
329
325
330
return CommitMultiple .builder ().id (projectId ).branch (branch ).commitMessage (commitMessage ).actions (actions )
326
331
.authorName (authorName ).authorEmail (authorEmail ).build ();
0 commit comments