Merge branch 'stable-2.16' into stable-3.0
* stable-2.16: OutgoingEmail: Use UrlFormatter to get settings URL CommentSender: Use UrlFormatter to get URLs for file and comments Elasticsearch: Base the default number of shards on ES version Disallow change index task duplication AbstractPushForReview: Add tests for pushing with skip-validation option Set version to 2.16.10-SNAPSHOT Set version to 2.16.9 Documentation: Fix the Elasticsearch shards/replicas link ProjectControl: Allow regexes ref strings for uploads ProjectControl: Allow regexes ref strings for tags ProjectControl: Reuse constants for ref strings Add extension point to gr-user-header Change-Id: I6a38b9bfdc2bcbb8c457ce24883767f4579ca656
This commit is contained in:
@@ -75,21 +75,19 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
public List<Comment> comments = new ArrayList<>();
|
||||
|
||||
/** @return a web link to the given patch set and file. */
|
||||
public String getLink() {
|
||||
String url = getGerritUrl();
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
public String getFileLink() {
|
||||
return args.urlFormatter
|
||||
.get()
|
||||
.getPatchFileView(change, patchSetId, KeyUtil.encode(filename))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
return new StringBuilder()
|
||||
.append(url)
|
||||
.append("#/c/")
|
||||
.append(change.getId())
|
||||
.append('/')
|
||||
.append(patchSetId)
|
||||
.append('/')
|
||||
.append(KeyUtil.encode(filename))
|
||||
.toString();
|
||||
/** @return a web link to a comment within a given patch set and file. */
|
||||
public String getCommentLink(short side, int startLine) {
|
||||
return args.urlFormatter
|
||||
.get()
|
||||
.getInlineCommentView(change, patchSetId, KeyUtil.encode(filename), side, startLine)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +389,7 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
|
||||
for (CommentSender.FileCommentGroup group : getGroupedInlineComments(repo)) {
|
||||
Map<String, Object> groupData = new HashMap<>();
|
||||
groupData.put("link", group.getLink());
|
||||
groupData.put("link", group.getFileLink());
|
||||
groupData.put("title", group.getTitle());
|
||||
groupData.put("patchSetId", group.patchSetId);
|
||||
|
||||
@@ -420,11 +418,9 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
|
||||
// Set the comment link.
|
||||
if (comment.lineNbr == 0) {
|
||||
commentData.put("link", group.getLink());
|
||||
} else if (comment.side == 0) {
|
||||
commentData.put("link", group.getLink() + "@a" + startLine);
|
||||
commentData.put("link", group.getFileLink());
|
||||
} else {
|
||||
commentData.put("link", group.getLink() + '@' + startLine);
|
||||
commentData.put("link", group.getCommentLink(comment.side, startLine));
|
||||
}
|
||||
|
||||
// Set robot comment data.
|
||||
|
||||
@@ -282,16 +282,10 @@ public abstract class OutgoingEmail {
|
||||
}
|
||||
|
||||
public String getSettingsUrl() {
|
||||
if (getGerritUrl() != null) {
|
||||
final StringBuilder r = new StringBuilder();
|
||||
r.append(getGerritUrl());
|
||||
r.append("settings");
|
||||
return r.toString();
|
||||
}
|
||||
return null;
|
||||
return args.urlFormatter.get().getSettingsUrl().orElse(null);
|
||||
}
|
||||
|
||||
public String getGerritUrl() {
|
||||
private String getGerritUrl() {
|
||||
return args.urlFormatter.get().getWebUrl().orElse(null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user