contrib/release.py: consider positive feedbacks from testers

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2017-07-09 20:24:40 +02:00
parent 7d1a540598
commit ceb69c7033
2 changed files with 34 additions and 10 deletions

View File

@ -253,6 +253,9 @@ class Tester(object):
def getFeedback(self): def getFeedback(self):
return self.feedback return self.feedback
def positiveFeedback(self):
return self.feedback is True
def setFeedback(self, feedback): def setFeedback(self, feedback):
assert feedback in [True, False, None] assert feedback in [True, False, None]
self.feedback = feedback self.feedback = feedback
@ -263,10 +266,11 @@ class Tester(object):
class Testers(object): class Testers(object):
def __init__(self): def __init__(self):
self.testers = [] self.testers = None
self._read() self._read()
def _read(self): def _read(self):
self.testers = []
with open(TESTERS_FILE, 'r') as fd: with open(TESTERS_FILE, 'r') as fd:
testers = yaml.load(fd) testers = yaml.load(fd)
for tester in testers: for tester in testers:
@ -299,6 +303,13 @@ class Testers(object):
testersList += "- {}\n".format(tester.getName()) testersList += "- {}\n".format(tester.getName())
return testersList return testersList
def getListOk(self):
testersOk = []
for tester in self.testers:
if tester.positiveFeedback():
testersOk.append(tester)
return testersOk
def reset(self): def reset(self):
for tester in self.testers: for tester in self.testers:
tester.setFeedback(None) tester.setFeedback(None)

View File

@ -112,11 +112,14 @@ class State(object):
def restore(self): def restore(self):
Git.chdirToRepositoryTopLevel() Git.chdirToRepositoryTopLevel()
Git.checkout('-f') try:
Git.checkout('master') Git.checkout('-f')
Git.resetKeep(self.master) except:
Git.checkout('next') pass
Git.resetKeep(self.next) # Git.checkout('master')
# Git.resetKeep(self.master)
# Git.checkout('next')
# Git.resetKeep(self.next)
if self.tag is not None: if self.tag is not None:
Git.rmTag(self.tag) Git.rmTag(self.tag)
@ -152,7 +155,9 @@ class Changelog(object):
return False return False
def showPrevious(self): def showPrevious(self):
return run(shlex.split("tail {}".format(CHANGELOG_EXCERPT_OLD))) output = run(shlex.split("cat '{}'".format(CHANGELOG_EXCERPT_OLD)))
for line in output.splitlines():
print(line.decode('utf-8')) # Weird to have to decode bytes here.
def usePrevious(self): def usePrevious(self):
rename(CHANGELOG_EXCERPT_OLD, CHANGELOG_EXCERPT) rename(CHANGELOG_EXCERPT_OLD, CHANGELOG_EXCERPT)
@ -354,9 +359,13 @@ class Release(object):
if not self.changelog.usingPrevious(): if not self.changelog.usingPrevious():
date = datetime.now().strftime('%Y-%m-%d') date = datetime.now().strftime('%Y-%m-%d')
testersList = self.testers.getList() testersList = ""
testers = self.testers.getListOk()
authorsList = "" authorsList = ""
authors = Git.getAuthorsList(currentVersion) authors = Git.getAuthorsList(currentVersion)
for tester in testers:
testersList += "- {}\n".format(tester.getName())
for author in authors: for author in authors:
authorsList += "- {} ({})\n".format( authorsList += "- {} ({})\n".format(
author.getName(), author.getCount() author.getName(), author.getCount()
@ -386,7 +395,7 @@ class Release(object):
Git.add('offlineimap/__init__.py') Git.add('offlineimap/__init__.py')
Git.add('Changelog.md') Git.add('Changelog.md')
commitMsg = "{}\n".format(newVersion) commitMsg = "{}\n".format(newVersion)
for tester in self.testers.get(): for tester in self.testers.getListOk():
commitMsg = "{}\nTested-by: {} {}".format( commitMsg = "{}\nTested-by: {} {}".format(
commitMsg, tester.getName(), tester.getEmail() commitMsg, tester.getName(), tester.getEmail()
) )
@ -441,7 +450,11 @@ if __name__ == '__main__':
release.after() release.after()
websiteBranch = release.getWebsiteBranch() websiteBranch = release.getWebsiteBranch()
print(END_MESSAGE.format(ANNOUNCE_FILE, newVersion, websiteBranch)) print(END_MESSAGE.format(
announce=ANNOUNCE_FILE,
new_version=newVersion,
website_branch=websiteBranch)
)
except Exception as e: except Exception as e:
release.restore() release.restore()
raise raise