Skip to content

Commit 609c1e5

Browse files
committed
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" submitgit/pretend-git#1 (comment)
1 parent 95d66d1 commit 609c1e5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/lib/MailType.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.madgag.github.Implicits._
55
import controllers.routes
66
import lib.actions.Requests._
77
import lib.checks.{Check, GHChecks, PRChecks}
8-
import org.kohsuke.github.{GHMyself, GHPullRequest}
8+
import org.kohsuke.github.{GHCompare, GHMyself, GHPullRequest}
99
import play.api.mvc.RequestHeader
1010

1111
import scala.concurrent.ExecutionContext.Implicits.global
@@ -108,8 +108,20 @@ object MailType {
108108

109109
override def afterSending(pr: GHPullRequest, messageId: String, prMailSettings: PRMailSettings) = {
110110
val mailingListLinks = Project.byRepoId(pr.id.repo).mailingList.archives.map(a => s"[${a.providerName}](${a.linkFor(messageId)})").mkString(", ")
111+
112+
val ghCompare = pr.getRepository.getCompare(pr.getBase.getSha, pr.getHead.getSha)
113+
// lazy way of constructing https://github.com/submitgit/pretend-git/compare/7c597ef345aed345576de616c51f27e6f4b342b3...f90334356a304bc0acad01ab4fc64c49a3afd371
114+
val prCompareSnapshotUrl = ghCompare.getHtmlUrl
115+
116+
val numCommits = ghCompare.getTotalCommits
117+
val patchBombDesc = if (numCommits == 1) {
118+
s"this commit ($prCompareSnapshotUrl) as a patch"
119+
} else {
120+
s"these $numCommits commits ($prCompareSnapshotUrl) as a set of patches"
121+
}
122+
111123
pr.comment(
112-
s"${pr.getUser.atLogin} sent this to the mailing list with [_submitGit_](https://github.com/rtyley/submitgit) - " +
124+
s"${pr.getUser.atLogin} sent $patchBombDesc to the mailing list with [_submitGit_](https://github.com/rtyley/submitgit) - " +
113125
s"here on $mailingListLinks []($messageId)")
114126
prMailSettings.afterBeingUsedToSend(messageId)
115127
}

0 commit comments

Comments
 (0)