From 609c1e5982f258f8cf63078d886446fabf89cd7a Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Mon, 26 Oct 2015 21:01:52 +0000 Subject: [PATCH] Specify precisely what commits got sent to the mailing list "@rtyley sent this commit (7c597ef...f903343) as a patch to the mailing list with submitGit - here on Google Groups" https://github.com/submitgit/pretend-git/pull/1#issuecomment-151283442 --- app/lib/MailType.scala | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/lib/MailType.scala b/app/lib/MailType.scala index e796566..94750fa 100644 --- a/app/lib/MailType.scala +++ b/app/lib/MailType.scala @@ -5,7 +5,7 @@ import com.madgag.github.Implicits._ import controllers.routes import lib.actions.Requests._ import lib.checks.{Check, GHChecks, PRChecks} -import org.kohsuke.github.{GHMyself, GHPullRequest} +import org.kohsuke.github.{GHCompare, GHMyself, GHPullRequest} import play.api.mvc.RequestHeader import scala.concurrent.ExecutionContext.Implicits.global @@ -108,8 +108,20 @@ object MailType { override def afterSending(pr: GHPullRequest, messageId: String, prMailSettings: PRMailSettings) = { val mailingListLinks = Project.byRepoId(pr.id.repo).mailingList.archives.map(a => s"[${a.providerName}](${a.linkFor(messageId)})").mkString(", ") + + val ghCompare = pr.getRepository.getCompare(pr.getBase.getSha, pr.getHead.getSha) + // lazy way of constructing https://github.com/submitgit/pretend-git/compare/7c597ef345aed345576de616c51f27e6f4b342b3...f90334356a304bc0acad01ab4fc64c49a3afd371 + val prCompareSnapshotUrl = ghCompare.getHtmlUrl + + val numCommits = ghCompare.getTotalCommits + val patchBombDesc = if (numCommits == 1) { + s"this commit ($prCompareSnapshotUrl) as a patch" + } else { + s"these $numCommits commits ($prCompareSnapshotUrl) as a set of patches" + } + pr.comment( - s"${pr.getUser.atLogin} sent this to the mailing list with [_submitGit_](https://github.com/rtyley/submitgit) - " + + s"${pr.getUser.atLogin} sent $patchBombDesc to the mailing list with [_submitGit_](https://github.com/rtyley/submitgit) - " + s"here on $mailingListLinks []($messageId)") prMailSettings.afterBeingUsedToSend(messageId) }