list-fixed-bugs.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/python3
  2. # Copyright (C) 2015-2026 Free Software Foundation, Inc.
  3. # This file is part of the GNU C Library.
  4. #
  5. # The GNU C Library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9. #
  10. # The GNU C Library is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public
  16. # License along with the GNU C Library; if not, see
  17. # <https://www.gnu.org/licenses/>.
  18. """List fixed bugs for the NEWS file.
  19. This script takes a version number as input and generates a list of
  20. bugs marked as FIXED with that milestone, to be added to the NEWS file
  21. just before release. The output is in UTF-8.
  22. """
  23. import argparse
  24. import json
  25. import sys
  26. import textwrap
  27. import urllib.request
  28. def get_parser():
  29. """Return an argument parser for this module."""
  30. parser = argparse.ArgumentParser(description=__doc__)
  31. parser.add_argument('version',
  32. help='Release version to look up')
  33. return parser
  34. def list_fixed_bugs(version):
  35. """List the bugs fixed in a given version."""
  36. url = ('https://sourceware.org/bugzilla/rest.cgi/bug?product=glibc'
  37. '&resolution=FIXED&target_milestone=%s'
  38. '&include_fields=id,component,summary' % version)
  39. response = urllib.request.urlopen(url)
  40. json_data = response.read().decode('utf-8')
  41. data = json.loads(json_data)
  42. for bug in data['bugs']:
  43. desc = '[%d] %s: %s' % (bug['id'], bug['component'], bug['summary'])
  44. desc = textwrap.fill(desc, width=72, initial_indent=' ',
  45. subsequent_indent=' ') + '\n'
  46. sys.stdout.buffer.write(desc.encode('utf-8'))
  47. def main(argv):
  48. """The main entry point."""
  49. parser = get_parser()
  50. opts = parser.parse_args(argv)
  51. list_fixed_bugs(opts.version)
  52. if __name__ == '__main__':
  53. main(sys.argv[1:])