Skip to content
Permalink
Browse files
382: List commits that have been pushed in integration message
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Apr 27, 2020
1 parent 75f257e commit 9bf3f5cb979e25c1d15a6e03f50dc8f78712dd1b
@@ -442,7 +442,16 @@ private String getMergeReadyComment(String commitMessage, List<Review> reviews)
}
message.append("pushed to the `");
message.append(pr.targetRef());
message.append("` branch. ");
message.append("` branch:\n\n");
divergingCommits.stream()
.limit(10)
.forEach(c -> message.append(" * ").append(c.hash().hex()).append(": ").append(c.message().get(0)).append("\n"));
if (divergingCommits.size() > 10) {
message.append(" * ... and ").append(divergingCommits.size() - 10).append(" more: ")
.append(pr.repository().webUrl(baseHash.hex(), pr.targetRef())).append("\n");
}

message.append("\n");
message.append("As there are no conflicts, your changes will automatically be rebased on top of ");
message.append("these commits when integrating. If you prefer to avoid automatic rebasing, please merge `");
message.append(pr.targetRef());
@@ -528,6 +528,7 @@ void mergeMessage(TestInfo testInfo) throws IOException {
// The bot should reply with an ok message
var updated = pr.comments().stream()
.filter(comment -> comment.body().contains("there has been 1 commit"))
.filter(comment -> comment.body().contains(" * " + unrelatedHash.abbreviate()))
.filter(comment -> comment.body().contains("please merge"))
.count();
assertEquals(1, updated);
@@ -101,6 +101,11 @@ public URI webUrl(Hash hash) {
return null;
}

@Override
public URI webUrl(String baseRef, String headRef) {
return null;
}

@Override
public VCS repositoryType() {
return null;
@@ -58,6 +58,7 @@ PullRequest createPullRequest(HostedRepository target,
URI webUrl();
URI nonTransformedWebUrl();
URI webUrl(Hash hash);
URI webUrl(String baseRef, String headRef);
VCS repositoryType();
String fileContents(String filename, String ref);
String namespace();
@@ -200,6 +200,12 @@ public URI webUrl(Hash hash) {
return gitHubHost.getWebURI(endpoint);
}

@Override
public URI webUrl(String baseRef, String headRef) {
var endpoint = "/" + repository + "/compare/" + baseRef + "..." + headRef;
return gitHubHost.getWebURI(endpoint);
}

@Override
public VCS repositoryType() {
return VCS.GIT;
@@ -179,6 +179,13 @@ public URI webUrl(Hash hash) {
.build();
}

@Override
public URI webUrl(String baseRef, String headRef) {
return URIBuilder.base(gitLabHost.getUri())
.setPath("/" + projectName + "/compare/" + baseRef + "..." + headRef)
.build();
}

@Override
public VCS repositoryType() {
return VCS.GIT;
@@ -133,11 +133,12 @@ public URI nonTransformedWebUrl() {

@Override
public URI webUrl(Hash hash) {
try {
return new URI(url().toString() + "/" + hash.hex());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
return URI.create(url().toString() + "/" + hash.hex());
}

@Override
public URI webUrl(String baseRef, String headRef) {
return URI.create(url().toString() + "/" + baseRef + "..." + headRef);
}

@Override

0 comments on commit 9bf3f5c

Please sign in to comment.