]> granicus.if.org Git - icinga2/blob - changelog.py
Remove unused variable
[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
22
23 if len(sys.argv) < 2:
24     print "Usage:", sys.argv[0], "<VERSION>"
25     sys.exit(0)
26
27 version_name = sys.argv[1]
28
29 rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/versions.json")
30 versions_data = json.loads(rsp.read())
31
32 version_id = None
33
34 for version in versions_data["versions"]:
35     if version["name"] == version_name:
36         version_id = version["id"]
37         break
38
39 if version_id == None:
40     print "Version '%s' not found." % (version_name)
41     sys.exit(1)
42
43 changes = ""
44
45 for field in version["custom_fields"]:
46     if field["id"] == 14:
47         changes = field["value"]
48         break
49
50 print "### What's New in Version %s" % (version_name)
51 print ""
52 print "#### Changes"
53 print ""
54 print changes
55 print ""
56 print "#### Issues"
57 print ""
58
59 offset = 0
60
61 log_entries = []
62
63 while True:
64     # We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
65     # for some of the older tickets:
66     rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (offset, version_id))
67     issues_data = json.loads(rsp.read())
68     issues_count = len(issues_data["issues"])
69     offset = offset + issues_count
70
71     if issues_count == 0:
72         break
73
74     for issue in issues_data["issues"]:
75         ignore_issue = False
76
77         for field in issue["custom_fields"]:
78             if field["id"] == 13 and "value" in field and field["value"] == "0":
79                 ignore_issue = True
80                 break
81
82         if ignore_issue:
83             continue
84
85         log_entries.append((issue["tracker"]["name"], issue["id"], issue["subject"]))
86
87 for p in range(2):
88     not_empty = False
89
90     for log_entry in sorted(log_entries):
91         if (p == 0 and log_entry[0] == "Feature") or (p == 1 and log_entry[0] != "Feature"):
92             print "* %s %d: %s" % log_entry
93             not_empty = True
94
95     if not_empty:
96         print ""
97
98 sys.exit(0)