summaryrefslogtreecommitdiffstats
path: root/src/site/templates/ghreleasenotes.awk
blob: f44795528644127d4022e3407f10416a7e188fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/bin/env awk -f

BEGIN { on=0 ; skip=1 ; block=0 ; section=""}

/^[[:blank:]]*id:/ { relId = $NF }

/r[0-9]+: *{/ { on=1 ; next }
/^[[:blank:]]*}[[:blank:]]*$/ { if (on) {
                                	print "[Full release notes on gitblit.com](http://gitblit.com/releases.html#" relId ")"
                                	exit 0
                                }
                              }


on==1 && /^[[:blank:]]*[[:alnum:]]+:[[:blank:]]*(''|~)?$/ {
															if (!block) {
																skip=1
																if (section == "fixes:" || section == "changes:" || section == "additions:") { printf "\n</details>\n"}
																if (section != "") print ""
																if (section == "note:") print "----------"
																section = ""
																if ($NF == "~") next
															}
															else {
																printSection()
																next
															}
															if ($NF == "''") {
																block = !block
															}
														}
on==1 && /^[[:blank:]]*note:/ { skip=0 ; section=$1; print "### Update Note" ; printSingleLineSection() ; next }
on==1 && /^[[:blank:]]*text:/ { skip=0 ; section=$1; printf "\n\n"; printSingleLineSection() ; next }
on==1 && /^[[:blank:]]*security:/ { skip=0 ; section=$1; print "### *Security*" ; next }
on==1 && /^[[:blank:]]*fixes:/ { skip=0 ; section=$1; printf "<details><summary>Fixes</summary>\n\n### Fixes\n" ; next}
on==1 && /^[[:blank:]]*changes:/ { skip=0 ; section=$1; printf "<details><summary>Changes</summary>\n\n### Changes\n" ; next}
on==1 && /^[[:blank:]]*additions:/ { skip=0 ; section=$1; printf "<details><summary>Additions</summary>\n\n### Additions\n" ; next}

on==1 {
 	if ($1 == "''") {
 		block = !block
 		next
 	}
 	if ((block || !skip))  {
 		printSection()
 	}
 }

function printSingleLineSection()
{
	if (NF>1 && $2 != "''" && $2 != "~") {
		if (protect) gsub(/'/, "'\\''")
		for (i=2; i<= NF; i++) printf "%s ", $i
		print ""
	}
}

function printSection()
{
 	if (section != "text:") sub(/[[:blank:]]+/, "")
 	gsub(/pr-/, "PR #")
 	gsub(/issue-/, "issue #")
 	gsub(/commit-/, "commit ")
 	if (protect) gsub(/'/, "'\\''")
 	print $0	
}