]> granicus.if.org Git - icinga2/blob - changelog.py
Add timestamp option for checkresult test script
[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>"
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 changes = string.join(string.split(changes, "\r\n"), "\n")
51
52 print "### What's New in Version %s" % (version_name)
53 print ""
54 print "#### Changes"
55 print ""
56 print changes
57 print ""
58 print "#### Issues"
59 print ""
60
61 offset = 0
62
63 log_entries = []
64
65 while True:
66     # We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
67     # for some of the older tickets:
68     rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (offset, version_id))
69     issues_data = json.loads(rsp.read())
70     issues_count = len(issues_data["issues"])
71     offset = offset + issues_count
72
73     if issues_count == 0:
74         break
75
76     for issue in issues_data["issues"]:
77         ignore_issue = False
78
79         for field in issue["custom_fields"]:
80             if field["id"] == 13 and "value" in field and field["value"] == "0":
81                 ignore_issue = True
82                 break
83
84         if ignore_issue:
85             continue
86
87         log_entries.append((issue["tracker"]["name"], issue["id"], issue["subject"].strip()))
88
89 for p in range(2):
90     not_empty = False
91
92     for log_entry in sorted(log_entries):
93         if (p == 0 and log_entry[0] == "Feature") or (p == 1 and log_entry[0] != "Feature"):
94             print "* %s %d: %s" % log_entry
95             not_empty = True
96
97     if not_empty:
98         print ""
99
100 sys.exit(0)