2 #/******************************************************************************
4 # * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
6 # * This program is free software; you can redistribute it and/or *
7 # * modify it under the terms of the GNU General Public License *
8 # * as published by the Free Software Foundation; either version 2 *
9 # * of the License, or (at your option) any later version. *
11 # * This program is distributed in the hope that it will be useful, *
12 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 # * GNU General Public License for more details. *
16 # * You should have received a copy of the GNU General Public License *
17 # * along with this program; if not, write to the Free Software Foundation *
18 # * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 # ******************************************************************************/
21 import urllib2, json, sys, string
24 print "Usage:", sys.argv[0], "<VERSION>", "[link-issues]"
27 version_name = sys.argv[1]
29 link_issues = (len(sys.argv) >= 3 and sys.argv[2] == "link-issues")
30 issue_url = "https://dev.icinga.org/issues/"
32 rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/versions.json")
33 versions_data = json.loads(rsp.read())
37 for version in versions_data["versions"]:
38 if version["name"] == version_name:
39 version_id = version["id"]
42 if version_id == None:
43 print "Version '%s' not found." % (version_name)
48 for field in version["custom_fields"]:
50 changes = field["value"]
53 changes = string.join(string.split(changes, "\r\n"), "\n")
55 print "### What's New in Version %s" % (version_name)
69 # We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
70 # for some of the older tickets:
71 rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (offset, version_id))
72 issues_data = json.loads(rsp.read())
73 issues_count = len(issues_data["issues"])
74 offset = offset + issues_count
79 for issue in issues_data["issues"]:
82 for field in issue["custom_fields"]:
83 if field["id"] == 13 and "value" in field and field["value"] == "0":
90 log_entries.append((issue["tracker"]["name"], issue["id"], issue["subject"].strip()))
95 for log_entry in sorted(log_entries):
96 if (p == 0 and log_entry[0] == "Feature") or (p == 1 and log_entry[0] != "Feature"):
98 print "* %s %d: %s" % log_entry
100 print "* {0} [{1}]({3}{1} \"{0} {1}\"): {2}".format(log_entry[0], log_entry[1], log_entry[2], issue_url)