You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ghreleasenotes.awk 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /usr/bin/env awk -f
  2. BEGIN { on=0 ; skip=1 ; block=0 ; section=""}
  3. /^[[:blank:]]*id:/ { relId = $NF }
  4. /r[0-9]+: *{/ { on=1 ; next }
  5. /^[[:blank:]]*}[[:blank:]]*$/ { if (on) {
  6. print "[Full release notes on gitblit.com](http://gitblit.com/releases.html#" relId ")"
  7. exit 0
  8. }
  9. }
  10. on==1 && /^[[:blank:]]*[[:alnum:]]+:[[:blank:]]*(''|~)?$/ {
  11. if (!block) {
  12. skip=1
  13. if (section == "fixes:" || section == "changes:" || section == "additions:") { printf "\n</details>\n"}
  14. if (section != "") print ""
  15. if (section == "note:") print "----------"
  16. section = ""
  17. if ($NF == "~") next
  18. }
  19. else {
  20. printSection()
  21. next
  22. }
  23. if ($NF == "''") {
  24. block = !block
  25. }
  26. }
  27. on==1 && /^[[:blank:]]*note:/ { skip=0 ; section=$1; print "### Update Note" ; printSingleLineSection() ; next }
  28. on==1 && /^[[:blank:]]*text:/ { skip=0 ; section=$1; printf "\n\n"; printSingleLineSection() ; next }
  29. on==1 && /^[[:blank:]]*security:/ { skip=0 ; section=$1; print "### *Security*" ; next }
  30. on==1 && /^[[:blank:]]*fixes:/ { skip=0 ; section=$1; printf "<details><summary>Fixes</summary>\n\n### Fixes\n" ; next}
  31. on==1 && /^[[:blank:]]*changes:/ { skip=0 ; section=$1; printf "<details><summary>Changes</summary>\n\n### Changes\n" ; next}
  32. on==1 && /^[[:blank:]]*additions:/ { skip=0 ; section=$1; printf "<details><summary>Additions</summary>\n\n### Additions\n" ; next}
  33. on==1 {
  34. if ($1 == "''") {
  35. block = !block
  36. next
  37. }
  38. if ((block || !skip)) {
  39. printSection()
  40. }
  41. }
  42. function printSingleLineSection()
  43. {
  44. if (NF>1 && $2 != "''" && $2 != "~") {
  45. if (protect) gsub(/'/, "'\\''")
  46. for (i=2; i<= NF; i++) printf "%s ", $i
  47. print ""
  48. }
  49. }
  50. function printSection()
  51. {
  52. if (section != "text:") sub(/[[:blank:]]+/, "")
  53. gsub(/pr-/, "PR #")
  54. gsub(/issue-/, "issue #")
  55. gsub(/commit-/, "commit ")
  56. if (protect) gsub(/'/, "'\\''")
  57. print $0
  58. }