2015-02-12 15:52:06 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#/******************************************************************************
|
|
|
|
# * Icinga 2 *
|
|
|
|
# * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
|
|
|
# * *
|
|
|
|
# * This program is free software; you can redistribute it and/or *
|
|
|
|
# * modify it under the terms of the GNU General Public License *
|
|
|
|
# * as published by the Free Software Foundation; either version 2 *
|
|
|
|
# * of the License, or (at your option) any later version. *
|
|
|
|
# * *
|
|
|
|
# * This program is distributed in the hope that it will be useful, *
|
|
|
|
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
# * GNU General Public License for more details. *
|
|
|
|
# * *
|
|
|
|
# * You should have received a copy of the GNU General Public License *
|
|
|
|
# * along with this program; if not, write to the Free Software Foundation *
|
|
|
|
# * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
# ******************************************************************************/
|
|
|
|
|
2015-03-09 12:47:01 +01:00
|
|
|
import urllib2, json, sys, string
|
2015-02-12 15:52:06 +01:00
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2015-04-27 13:32:13 +02:00
|
|
|
print "Usage:", sys.argv[0], "<VERSION>", "[link-issues]"
|
2015-02-12 15:52:06 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
version_name = sys.argv[1]
|
|
|
|
|
2015-04-27 13:32:13 +02:00
|
|
|
link_issues = (len(sys.argv) >= 3 and sys.argv[2] == "link-issues")
|
|
|
|
issue_url = "https://dev.icinga.org/issues/"
|
2015-06-18 13:26:59 +02:00
|
|
|
issue_project = "i2"
|
2015-04-27 13:32:13 +02:00
|
|
|
|
2015-06-18 13:26:59 +02:00
|
|
|
rsp = urllib2.urlopen("https://dev.icinga.org/projects/%s/versions.json" % (issue_project))
|
2015-02-12 15:52:06 +01:00
|
|
|
versions_data = json.loads(rsp.read())
|
|
|
|
|
|
|
|
version_id = None
|
|
|
|
|
|
|
|
for version in versions_data["versions"]:
|
|
|
|
if version["name"] == version_name:
|
|
|
|
version_id = version["id"]
|
2015-02-24 13:45:36 +01:00
|
|
|
break
|
2015-02-12 15:52:06 +01:00
|
|
|
|
|
|
|
if version_id == None:
|
|
|
|
print "Version '%s' not found." % (version_name)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2015-02-24 13:45:36 +01:00
|
|
|
changes = ""
|
|
|
|
|
2015-06-18 13:26:59 +02:00
|
|
|
if "custom_fields" in version:
|
|
|
|
for field in version["custom_fields"]:
|
|
|
|
if field["id"] == 14:
|
|
|
|
changes = field["value"]
|
|
|
|
break
|
2015-02-24 13:45:36 +01:00
|
|
|
|
2015-06-18 13:26:59 +02:00
|
|
|
changes = string.join(string.split(changes, "\r\n"), "\n")
|
2015-03-09 12:47:01 +01:00
|
|
|
|
2015-02-12 15:52:06 +01:00
|
|
|
print "### What's New in Version %s" % (version_name)
|
|
|
|
print ""
|
2015-06-18 13:26:59 +02:00
|
|
|
|
|
|
|
if changes:
|
|
|
|
print "#### Changes"
|
|
|
|
print ""
|
|
|
|
print changes
|
|
|
|
print ""
|
2015-02-12 15:52:06 +01:00
|
|
|
|
|
|
|
offset = 0
|
|
|
|
|
|
|
|
log_entries = []
|
|
|
|
|
|
|
|
while True:
|
|
|
|
# We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
|
|
|
|
# for some of the older tickets:
|
2015-06-18 13:26:59 +02:00
|
|
|
rsp = urllib2.urlopen("https://dev.icinga.org/projects/%s/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (issue_project, offset, version_id))
|
2015-02-12 15:52:06 +01:00
|
|
|
issues_data = json.loads(rsp.read())
|
|
|
|
issues_count = len(issues_data["issues"])
|
|
|
|
offset = offset + issues_count
|
|
|
|
|
|
|
|
if issues_count == 0:
|
|
|
|
break
|
|
|
|
|
|
|
|
for issue in issues_data["issues"]:
|
|
|
|
ignore_issue = False
|
|
|
|
|
2015-06-18 13:26:59 +02:00
|
|
|
if "custom_fields" in issue:
|
|
|
|
for field in issue["custom_fields"]:
|
|
|
|
if field["id"] == 13 and "value" in field and field["value"] == "0":
|
|
|
|
ignore_issue = True
|
|
|
|
break
|
2015-02-12 15:52:06 +01:00
|
|
|
|
2015-06-18 13:26:59 +02:00
|
|
|
if ignore_issue:
|
|
|
|
continue
|
2015-02-12 15:52:06 +01:00
|
|
|
|
2015-03-26 09:50:40 +01:00
|
|
|
log_entries.append((issue["tracker"]["name"], issue["id"], issue["subject"].strip()))
|
2015-02-12 15:52:06 +01:00
|
|
|
|
|
|
|
for p in range(2):
|
|
|
|
not_empty = False
|
|
|
|
|
2015-06-17 10:28:42 +02:00
|
|
|
for log_entry in log_entries:
|
|
|
|
if (p == 0 and log_entry[0] == "Feature") or (p == 1 and log_entry[0] != "Feature"):
|
|
|
|
not_empty = True
|
|
|
|
|
|
|
|
if not_empty:
|
|
|
|
print "####", "Features" if p == 0 else "Bugfixes"
|
|
|
|
print ""
|
|
|
|
|
2015-02-12 15:52:06 +01:00
|
|
|
for log_entry in sorted(log_entries):
|
|
|
|
if (p == 0 and log_entry[0] == "Feature") or (p == 1 and log_entry[0] != "Feature"):
|
2015-04-27 13:32:13 +02:00
|
|
|
if not link_issues:
|
|
|
|
print "* %s %d: %s" % log_entry
|
|
|
|
else:
|
|
|
|
print "* {0} [{1}]({3}{1} \"{0} {1}\"): {2}".format(log_entry[0], log_entry[1], log_entry[2], issue_url)
|
2015-02-12 15:52:06 +01:00
|
|
|
|
|
|
|
if not_empty:
|
|
|
|
print ""
|
|
|
|
|
|
|
|
sys.exit(0)
|