upcoming.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/python3
  2. """
  3. Put into Public Domain, by Nicolas Sebrecht.
  4. Produce the "upcoming release" notes.
  5. """
  6. from os import system
  7. from helpers import (
  8. MAILING_LIST, CACHEDIR, EDITOR, Testers, Git, OfflineimapInfo, User
  9. )
  10. UPCOMING_FILE = "{}/upcoming.txt".format(CACHEDIR)
  11. UPCOMING_HEADER = "{}/upcoming-header.txt".format(CACHEDIR)
  12. # Header is like:
  13. #
  14. #Message-Id: <{messageId}>
  15. #Date: {date}
  16. #From: {name} <{email}>
  17. #To: {mailinglist}
  18. #Cc: {ccList}
  19. #Subject: [ANNOUNCE] upcoming offlineimap v{expectedVersion}
  20. #
  21. ## Notes
  22. #
  23. #I think it's time for a new release.
  24. #
  25. #I aim to make the new release in one week, approximately. If you'd like more
  26. #time, please let me know. ,-)
  27. #
  28. #Please, send me a mail to confirm it works for you. This will be written in the
  29. #release notes and the git logs.
  30. #
  31. #
  32. ## Authors
  33. #
  34. if __name__ == '__main__':
  35. offlineimapInfo = OfflineimapInfo()
  36. print("Will read headers from {}".format(UPCOMING_HEADER))
  37. Git.chdirToRepositoryTopLevel()
  38. oVersion = offlineimapInfo.getVersion()
  39. ccList = Testers.listTestersInTeam()
  40. authors = Git.getAuthorsList(oVersion)
  41. for author in authors:
  42. email = author.getEmail()
  43. if email not in ccList:
  44. ccList.append(email)
  45. with open(UPCOMING_FILE, 'w') as upcoming, \
  46. open(UPCOMING_HEADER, 'r') as fd_header:
  47. header = {}
  48. header['messageId'] = Git.buildMessageId()
  49. header['date'] = Git.buildDate()
  50. header['name'], header['email'] = Git.getLocalUser()
  51. header['mailinglist'] = MAILING_LIST
  52. header['expectedVersion'] = User.request("Expected new version?")
  53. header['ccList'] = ", ".join(ccList)
  54. upcoming.write(fd_header.read().format(**header).lstrip())
  55. upcoming.write(Git.getShortlog(oVersion))
  56. upcoming.write("\n\n# Diffstat\n\n")
  57. upcoming.write(Git.getDiffstat(oVersion))
  58. upcoming.write("\n\n\n-- \n{}\n".format(Git.getLocalUser()[0]))
  59. system("{} {}".format(EDITOR, UPCOMING_FILE))
  60. print("{} written".format(UPCOMING_FILE))