]> granicus.if.org Git - icinga2/blob - changelog.py
Fix objects cache dump in compat for multiline vars
[icinga2] / changelog.py
1 #!/usr/bin/env python
2 #/******************************************************************************
3 # * Icinga 2                                                                   *
4 # * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org)    *
5 # *                                                                            *
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.                     *
10 # *                                                                            *
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.                               *
15 # *                                                                            *
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 # ******************************************************************************/
20
21 import urllib2, json, sys, string
22
23 if len(sys.argv) < 2:
24     print "Usage:", sys.argv[0], "<VERSION>", "[link-issues]"
25     sys.exit(0)
26
27 version_name = sys.argv[1]
28
29 link_issues = (len(sys.argv) >= 3 and sys.argv[2] == "link-issues")
30 issue_url = "https://dev.icinga.org/issues/"
31
32 rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/versions.json")
33 versions_data = json.loads(rsp.read())
34
35 version_id = None
36
37 for version in versions_data["versions"]:
38     if version["name"] == version_name:
39         version_id = version["id"]
40         break
41
42 if version_id == None:
43     print "Version '%s' not found." % (version_name)
44     sys.exit(1)
45
46 changes = ""
47
48 for field in version["custom_fields"]:
49     if field["id"] == 14:
50         changes = field["value"]
51         break
52
53 changes = string.join(string.split(changes, "\r\n"), "\n")
54
55 print "### What's New in Version %s" % (version_name)
56 print ""
57 print "#### Changes"
58 print ""
59 print changes
60 print ""
61 print "#### Issues"
62 print ""
63
64 offset = 0
65
66 log_entries = []
67
68 while True:
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
75
76     if issues_count == 0:
77         break
78
79     for issue in issues_data["issues"]:
80         ignore_issue = False
81
82         for field in issue["custom_fields"]:
83             if field["id"] == 13 and "value" in field and field["value"] == "0":
84                 ignore_issue = True
85                 break
86
87         if ignore_issue:
88             continue
89
90         log_entries.append((issue["tracker"]["name"], issue["id"], issue["subject"].strip()))
91
92 for p in range(2):
93     not_empty = False
94
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"):
97             if not link_issues:  
98                 print "* %s %d: %s" % log_entry
99             else:
100                 print "* {0} [{1}]({3}{1} \"{0} {1}\"): {2}".format(log_entry[0], log_entry[1], log_entry[2], issue_url)
101             not_empty = True
102
103     if not_empty:
104         print ""
105
106 sys.exit(0)