#!/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 => """%s""" format (si, si)) mkString ", " } // HTML Generation for Toni def commitShaLink(sha: String) = """%s""" format (sha,sha) def printBlankLine(): Unit = println("

 

") def printHeader4(msg: String): Unit = println("

%s

" format (msg)) def printCommiterList(): Unit = { printBlankLine() printHeader4("Special thanks to all the contribtuors!") println("""""") for((author, count) <- authors) println("""""" format (count, author)) println("""
#Author
%d  %s
""") } def printCommitList(): Unit = { printBlankLine() printHeader4("Complete commit list!") println("""""") for(commit <- commits) { println("") println("""""" format (commitShaLink(commit.sha), commit.header)) /*print("")*/ println("""""") } println("""
shaTitle
%s %s") (commit.body split "[\\r\\n]") foreach { line => print(line) print("
") } print("
""") } def issueFixPrinter(): Unit = { printBlankLine() printHeader4("Here's a list of isssues that have been fixed since %s" format (tag1)) println("""""") for(commit <- fixCommits) { println("""""" format(fixLinks(commit), commitShaLink(commit.sha), commit.header)) } println("""
Issue(s)CommitMessage
%s %s %s
""") printBlankLine() } def printHTML(): Unit = { println(""" %s - Release notes

A new release of Scala is available! Please point your build tools at %s

:: INSERT HAND GENERATED NOTES HERE ::

""" format(tag2, tag2 drop 1)) issueFixPrinter() printCommiterList() printCommitList() println("""""") } printHTML()