Skip to content

Commit

Permalink
Merge pull request #118 from dwasinge/update-fixes
Browse files Browse the repository at this point in the history
Bug Fixes:  Commit Message Aggregation and Launch Failure
  • Loading branch information
pabrahamsson authored Nov 2, 2020
2 parents 1cb6b1b + 489d4eb commit 7898171
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public Engagement update(Engagement engagement) {
() -> new WebApplicationException("no engagement found, use POST to create", HttpStatus.SC_NOT_FOUND));

validateCustomerAndProjectNames(engagement, existing);
setBeforeUpdate(engagement);
setBeforeUpdate(engagement, existing);
String currentLastUpdated = setLastUpdate(existing);
boolean skipLaunch = skipLaunch(engagement);
boolean skipLaunch = skipLaunch(existing);

Engagement updated = repository.updateEngagementIfLastUpdateMatched(engagement, currentLastUpdated, skipLaunch)
.orElseThrow(() -> new WebApplicationException(
Expand Down Expand Up @@ -203,21 +203,22 @@ void validateCustomerAndProjectNames(Engagement toUpdate, Engagement existing) {
* the data store.
*
* @param engagement
* @param existing
*/
void setBeforeUpdate(Engagement engagement) {
void setBeforeUpdate(Engagement engagement, Engagement existing) {

// mark as updated, if action not already assigned
setEngagementAction(engagement, FileAction.update);

// aggregate commit messages if already set
if (null != engagement.getCommitMessage()) {
if (null != existing.getCommitMessage()) {

// get existing message
String existing = engagement.getCommitMessage();
String existingMessage = existing.getCommitMessage();

// if another message on current request, append to existing message
String message = (null == engagement.getCommitMessage()) ? existing
: new StringBuilder(existing).append("\n\n").append(engagement.getCommitMessage()).toString();
String message = (null == engagement.getCommitMessage()) ? existingMessage
: new StringBuilder(existingMessage).append("\n\n").append(engagement.getCommitMessage()).toString();

// set the message on the engagement before persisting
engagement.setCommitMessage(message);
Expand Down

0 comments on commit 7898171

Please sign in to comment.