Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Merge: changed merge commit message
Browse files Browse the repository at this point in the history
Add receiving branch's name if the branch is not refs/heads/master.
Omit sending project's owner and name if the project is same with receiving project.
  • Loading branch information
Keesun Baik committed Mar 10, 2015
1 parent a6d17fc commit 7099e70
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions app/models/PullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import utils.Constants;
import utils.JodaDateUtil;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.*;
import javax.persistence.OrderBy;
Expand Down Expand Up @@ -597,11 +598,43 @@ public Set<User> getWatchers() {
return Watch.findActualWatchers(actualWatchers, asResource());
}

/**
* Make merge commit message e.g.
*
* Merge branch 'dev' of dlab/hive into 'next'
*
* from pull-request 10
*
* @param commits
* @return
* @throws IOException
*/
private String makeMergeCommitMessage(List<GitCommit> commits) throws IOException {
StringBuilder builder = new StringBuilder();
builder.append(String.format("Merge branch '%s' of %s/%s\n\n",
this.fromBranch.replace("refs/heads/", ""), fromProject.owner, fromProject.name));
builder.append("from pull-request " + number + "\n\n");
builder.append("Merge branch ");
builder.append("\'");
builder.append(Repository.shortenRefName(fromBranch));
builder.append("\'");

if (!fromProject.equals(toProject)) {
builder.append(" of ");
builder.append(fromProject.owner);
builder.append("/");
builder.append(fromProject.name);
}

if (toBranch.equals("refs/heads/master")) {
builder.append("\n\n");
} else {
builder.append(" into ");
builder.append("\'");
builder.append(Repository.shortenRefName(toBranch));
builder.append("\'");
builder.append("\n\n");
}
builder.append("from pull-request ");
builder.append(number);
builder.append("\n\n");
addCommitMessages(commits, builder);
addReviewers(builder);
return builder.toString();
Expand Down

0 comments on commit 7099e70

Please sign in to comment.