diff options
-rwxr-xr-x | tools/make-release-notes | 49 | ||||
-rw-r--r-- | tools/make-release-notes.scala | 129 |
2 files changed, 129 insertions, 49 deletions
diff --git a/tools/make-release-notes b/tools/make-release-notes deleted file mode 100755 index dcd206f7fc..0000000000 --- a/tools/make-release-notes +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -# This tool is used to build a *scaffold* of a release note that you can fill in details with before posting to the list. -# It aims to provide *all* the information you need, and probably need to prune it before releasing. -# Author: jsuereth - -fixMessages() { - local tag1="$1" - local tag2="$2" - git log $tag1..$tag2 "--format=format: * %h - %s" --no-merges --grep "SI-" -} - -allcommitMessages() { - local tag1="$1" - local tag2="$2" - git log $tag1..$tag2 "--format=format: * %h - %s" --no-merges -} - -authors() { - local tag1="$1" - local tag2="$2" - git log $tag1..$tag2 --format=format:%an --no-merges | sort | uniq -c | sort -rh -} - - -message() { - local tag1="$1" - local tag2="$2" - - echo "A new release of Scala is available! Please point your build tools at ${tag2#v}" - echo - echo "Here's a list of the issues that have been fixed since ${tag1#v}: " - fixMessages "$tag1" "$tag2" - echo - echo - echo "Special thanks to all the contributions!" - echo "------- --------------------------------" - authors "$tag1" "$tag2" - echo "------- --------------------------------" - echo - echo - echo "Here's a complete list of changes:" - allcommitMessages "$tag1" "$tag2" -} - - -message "$1" "$2" - - diff --git a/tools/make-release-notes.scala b/tools/make-release-notes.scala new file mode 100644 index 0000000000..3e5b60d223 --- /dev/null +++ b/tools/make-release-notes.scala @@ -0,0 +1,129 @@ +#!/bin/sh +exec scala -feature $0 $@ +!# + +import sys.process._ + +val tag1 = "v2.10.0-M4" +val tag2 = "v2.10.0-M5" + +// Git commit parsing magikz + +case class Commit(sha: String, author: String, header: String, body: String) { + override def toString = " * " + sha + " (" + author + ") " + header + " - " + body.take(5) + " ..." +} + +val gitFormat = "--format=format:*-*%h``%aN``%s``%b" + +def processGitCommits(input: String): IndexedSeq[Commit] = + ((input split "[\\r\\n]*\\*\\-\\*").view map (_ split "``") collect { + case Array(sha, author, hdr, msg) => Commit(sha, author, hdr, msg) + }).toVector + +val commits = + processGitCommits(Process(Seq("git", "log", tag1+".."+tag2,"--format=format:*-*%h``%aN``%s``%b","--no-merges")).!!) + +val authors: Seq[(String, Int)] = { + val grouped: Vector[(String,Int)] = (commits groupBy (_.author)).map { case (a,c) => a -> c.length }{collection.breakOut} + (grouped sortBy (_._2)).reverse +} + +def hasFixins(msg: String): Boolean = ( + (msg contains "SI-") /*&& ((msg.toLowerCase contains "fix") || (msg.toLowerCase contains "close"))*/ +) + +val fixCommits = + for { + commit <- commits + searchString = commit.body + commit.header + if hasFixins(searchString) + } yield commit + + +val siPattern = java.util.regex.Pattern.compile("(SI-[0-9]+)") + +def fixLinks(commit: Commit): String = { + val searchString = commit.body + commit.header + val m = siPattern matcher searchString + val issues = new collection.mutable.ArrayBuffer[String] + while(m.find()) { + issues += (m group 1) + } + issues map (si => """<a href="https://issues.scala-lang.org/browse/%s">%s</a>""" format (si, si)) mkString ", " +} + + +// HTML Generation for Toni + +def commitShaLink(sha: String) = + """<a href="https://github.com/scala/scala/commit/%s">%s</a>""" format (sha,sha) + +def printBlankLine(): Unit = println("<p> </p>") +def printHeader4(msg: String): Unit = println("<h4>%s</h4>" format (msg)) + +def printCommiterList(): Unit = { + printBlankLine() + printHeader4("Special thanks to all the contribtuors!") + println("""<table border="0" cellspacing="0" cellpadding="1"> + <thead><tr><th>#</th><th align="left">Author</th></tr></thead> + <tbody>""") + for((author, count) <- authors) + println("""<tr><td align="right">%d </td><td>%s</td></tr>""" format (count, author)) + println("""</tbody> +</table>""") +} + +def printCommitList(): Unit = { + printBlankLine() + printHeader4("Complete commit list!") + println("""<table border="0" cellspacing="0" cellpadding="1"> + <thead><tr><th>sha</th><th align="left">Title</th></tr></thead> + <tbody>""") + for(commit <- commits) { + println("<tr>") + println("""<td align="right">%s </td><td>%s</td>""" format (commitShaLink(commit.sha), commit.header)) + /*print("<td>") + (commit.body split "[\\r\\n]") foreach { line => + print(line) + print("<br/>") + } + print("</td>")*/ + println("""</tr>""") + } + println("""</tbody> +</table>""") +} + +def issueFixPrinter(): Unit = { + printBlankLine() + printHeader4("Here's a list of isssues that have been fixed since %s" format (tag1)) + println("""<table border="0" cellspacing="0" cellpading="1"> + <thead><tr><th>Issue(s)</th><th>Commit</th><th>Message</th></tr></thead> + <tbody>""") + for(commit <- fixCommits) { + println("""<tr><td>%s </td><td>%s </td><td>%s</td></tr>""" format(fixLinks(commit), commitShaLink(commit.sha), commit.header)) + } + println("""</tbody> +</table>""") + printBlankLine() +} + +def printHTML(): Unit = { + println("""<html> + <head> + <title>%s - Release notes</title> + </head> + <body> + <h3>A new release of Scala is available! Please point your build tools at %s</h3> + <p>:: INSERT HAND GENERATED NOTES HERE ::</p> +""" format(tag2, tag2 drop 1)) + issueFixPrinter() + printCommiterList() + printCommitList() + println("""</body></html>""") +} + +printHTML() + + + |