Expose the entire commit message instead of only the subject

Some callers are interested in the entire commit message, or more
specifically in the footers of the commit message. Hence, we expose the
entire commit message to give the callers more flexibility.

Original change that exposed the subject in I420161ca4.

Change-Id: I40341c4daee118a5b80958e7221abed835d52a05
This commit is contained in:
Gal Paikin
2021-01-07 15:52:00 +01:00
parent ae7b747dfa
commit bdcba6961d
7 changed files with 18 additions and 18 deletions

View File

@@ -2255,7 +2255,7 @@ public class MyWeblinkPlugin implements PatchSetWebLink {
@Override @Override
public WebLinkInfo getPatchSetWebLink(String projectName, String commit, public WebLinkInfo getPatchSetWebLink(String projectName, String commit,
String subject, String branchName) { String commitMessage, String branchName) {
return new WebLinkInfo(name, return new WebLinkInfo(name,
imageUrl, imageUrl,
String.format(placeHolderUrlProjectCommit, project, commit), String.format(placeHolderUrlProjectCommit, project, commit),

View File

@@ -32,11 +32,11 @@ public interface ParentWebLink extends WebLink {
* *
* @param projectName name of the project * @param projectName name of the project
* @param commit commit sha1 of the parent revision * @param commit commit sha1 of the parent revision
* @param subject first line of the commit message * @param commitMessage the commit messsage of the change
* @param branchName target branch of the change * @param branchName target branch of the change
* @return WebLinkInfo that links to parent commit in external service, null if there should be no * @return WebLinkInfo that links to parent commit in external service, null if there should be no
* link. * link.
*/ */
WebLinkInfo getParentWebLink( WebLinkInfo getParentWebLink(
String projectName, String commit, String subject, String branchName); String projectName, String commit, String commitMessage, String branchName);
} }

View File

@@ -32,11 +32,11 @@ public interface PatchSetWebLink extends WebLink {
* *
* @param projectName name of the project * @param projectName name of the project
* @param commit commit of the patch set * @param commit commit of the patch set
* @param subject first line of the commit message * @param commitMessage the commit message of the change
* @param branchName target branch of the change * @param branchName target branch of the change
* @return WebLinkInfo that links to patch set in external service, null if there should be no * @return WebLinkInfo that links to patch set in external service, null if there should be no
* link. * link.
*/ */
WebLinkInfo getPatchSetWebLink( WebLinkInfo getPatchSetWebLink(
String projectName, String commit, String subject, String branchName); String projectName, String commit, String commitMessage, String branchName);
} }

View File

@@ -86,29 +86,29 @@ public class WebLinks {
/** /**
* @param project Project name. * @param project Project name.
* @param commit SHA1 of commit. * @param commit SHA1 of commit.
* @param subject subject of the commit. * @param commitMessage the commit message of the commit.
* @param branchName branch of the commit. * @param branchName branch of the commit.
* @return Links for patch sets. * @return Links for patch sets.
*/ */
public ImmutableList<WebLinkInfo> getPatchSetLinks( public ImmutableList<WebLinkInfo> getPatchSetLinks(
Project.NameKey project, String commit, String subject, String branchName) { Project.NameKey project, String commit, String commitMessage, String branchName) {
return filterLinks( return filterLinks(
patchSetLinks, patchSetLinks,
webLink -> webLink.getPatchSetWebLink(project.get(), commit, subject, branchName)); webLink -> webLink.getPatchSetWebLink(project.get(), commit, commitMessage, branchName));
} }
/** /**
* @param project Project name. * @param project Project name.
* @param revision SHA1 of the parent revision. * @param revision SHA1 of the parent revision.
* @param subject subject of the parent revision. * @param commitMessage the commit message of the parent revision.
* @param branchName branch of the revision (and parent revision). * @param branchName branch of the revision (and parent revision).
* @return Links for patch sets. * @return Links for patch sets.
*/ */
public ImmutableList<WebLinkInfo> getParentLinks( public ImmutableList<WebLinkInfo> getParentLinks(
Project.NameKey project, String revision, String subject, String branchName) { Project.NameKey project, String revision, String commitMessage, String branchName) {
return filterLinks( return filterLinks(
parentLinks, parentLinks,
webLink -> webLink.getParentWebLink(project.get(), revision, subject, branchName)); webLink -> webLink.getParentWebLink(project.get(), revision, commitMessage, branchName));
} }
/** /**

View File

@@ -183,7 +183,7 @@ public class RevisionJson {
if (addLinks) { if (addLinks) {
ImmutableList<WebLinkInfo> links = ImmutableList<WebLinkInfo> links =
webLinks.getPatchSetLinks(project, commit.name(), commit.getShortMessage(), branchName); webLinks.getPatchSetLinks(project, commit.name(), commit.getFullMessage(), branchName);
info.webLinks = links.isEmpty() ? null : links; info.webLinks = links.isEmpty() ? null : links;
} }
@@ -194,7 +194,7 @@ public class RevisionJson {
i.subject = parent.getShortMessage(); i.subject = parent.getShortMessage();
if (addLinks) { if (addLinks) {
ImmutableList<WebLinkInfo> parentLinks = ImmutableList<WebLinkInfo> parentLinks =
webLinks.getParentLinks(project, parent.name(), parent.getShortMessage(), branchName); webLinks.getParentLinks(project, parent.name(), parent.getFullMessage(), branchName);
i.webLinks = parentLinks.isEmpty() ? null : parentLinks; i.webLinks = parentLinks.isEmpty() ? null : parentLinks;
} }
info.parents.add(i); info.parents.add(i);

View File

@@ -328,9 +328,9 @@ public class GitwebConfig {
@Override @Override
public WebLinkInfo getPatchSetWebLink( public WebLinkInfo getPatchSetWebLink(
String projectName, String commit, String subject, String branchName) { String projectName, String commit, String commitMessage, String branchName) {
if (revision != null) { if (revision != null) {
// subject and branchName are not needed, hence not used. // commitMessage and branchName are not needed, hence not used.
return link( return link(
revision revision
.replace("project", encode(projectName)) .replace("project", encode(projectName))
@@ -342,9 +342,9 @@ public class GitwebConfig {
@Override @Override
public WebLinkInfo getParentWebLink( public WebLinkInfo getParentWebLink(
String projectName, String commit, String subject, String branchName) { String projectName, String commit, String commitMessage, String branchName) {
// For Gitweb treat parent revision links the same as patch set links // For Gitweb treat parent revision links the same as patch set links
return getPatchSetWebLink(projectName, commit, subject, branchName); return getPatchSetWebLink(projectName, commit, commitMessage, branchName);
} }
@Override @Override

View File

@@ -1622,7 +1622,7 @@ public class RevisionIT extends AbstractDaemonTest {
new PatchSetWebLink() { new PatchSetWebLink() {
@Override @Override
public WebLinkInfo getPatchSetWebLink( public WebLinkInfo getPatchSetWebLink(
String projectName, String commit, String subject, String branchName) { String projectName, String commit, String commitMessage, String branchName) {
return expectedWebLinkInfo; return expectedWebLinkInfo;
} }
}; };