70
def get_bugs_from_changelog_entry(sourcepackagerelease, since_version):
71
"""Parse the changelog_entry in the sourcepackagerelease and return a
72
list of `IBug`s referenced by it.
74
changelog = sourcepackagerelease.aggregate_changelog(since_version)
76
# There are 2 main regexes to match. Each match from those can then
77
# have further multiple matches from the 3rd regex:
81
re_closes.finditer(changelog), re_lp_closes.finditer(changelog))
84
bug_match = re_bug_numbers.findall(match.group(0))
85
closes += map(int, bug_match)
90
bug = getUtility(IBugSet).get(bug_id)
67
99
def can_close_bugs(target):
68
100
"""Whether or not bugs should be closed in the given target.
119
151
source_queue_item.sourcepackagerelease, changesfile_object)
122
def close_bugs_for_sourcepublication(source_publication):
154
def close_bugs_for_sourcepublication(source_publication, since_version=None):
123
155
"""Close bugs for a given sourcepublication.
125
157
Given a `ISourcePackagePublishingHistory` close bugs mentioned in
131
163
sourcepackagerelease = source_publication.sourcepackagerelease
132
164
changesfile_object = sourcepackagerelease.upload_changesfile
134
# No changesfile available, cannot close bugs.
135
if changesfile_object is None:
138
166
close_bugs_for_sourcepackagerelease(
139
sourcepackagerelease, changesfile_object)
142
def close_bugs_for_sourcepackagerelease(source_release, changesfile_object):
167
sourcepackagerelease, changesfile_object, since_version)
170
def close_bugs_for_sourcepackagerelease(source_release, changesfile_object,
143
172
"""Close bugs for a given source.
145
174
Given a `ISourcePackageRelease` and a corresponding changesfile object,
146
175
close bugs mentioned in the changesfile in the context of the source.
177
If changesfile_object is None and since_version is supplied,
178
close all the bugs in changelog entries made after that version and up
179
to and including the source_release's version. It does this by parsing
180
the changelog on the sourcepackagerelease. This could be extended in
181
the future to deal with the changes file as well but there is no
182
requirement to do so right now.
148
bugs_to_close = get_bugs_from_changes_file(changesfile_object)
184
if since_version and source_release.changelog:
185
bugs_to_close = get_bugs_from_changelog_entry(
186
source_release, since_version=since_version)
187
elif changesfile_object:
188
bugs_to_close = get_bugs_from_changes_file(changesfile_object)
150
192
# No bugs to be closed by this upload, move on.
151
193
if not bugs_to_close: