Commit b68bccf1 authored by Adrien Oliva's avatar Adrien Oliva

fix(preparerelease): Hardened script

- Be robust against lightweight tags
- Build News.md and ChangeLog.md files compliants with hooks
Signed-off-by: Adrien Oliva's avatarAdrien Oliva <olivaa+gitlab@yapbreak.fr>
parent 5f418145
......@@ -67,21 +67,26 @@ class Project:
if not dryrun:
filehandle = open(self.changelog, "w")
filehandle.write("# ChangeLog\n\n")
filehandle.write("# ChangeLog\n")
for date, commits in self.commit_list.items():
printed_date = False
filehandle.write("\n")
for commit in commits:
if commit.binsha in self.tags.keys():
try:
message = self.tags[commit.binsha].tag.message.split(
"\n")[0]
except AttributeError:
message = "(Lightweight tag)"
filehandle.write("\n## {}\n\n{}\n\n{}\n\n".format(
os.path.basename(self.tags[commit.binsha].path),
self.tags[commit.binsha].tag.message.split("\n")[0],
message,
date))
printed_date = True
elif not printed_date:
filehandle.write("{}\n\n".format(date))
printed_date = True
filehandle.write("\t* {}\n".format(headline(commit)))
filehandle.write("\n")
filehandle.close()
def write_news(self, dryrun=True):
......@@ -93,7 +98,7 @@ class Project:
if not dryrun:
filehandle = open(self.news, "w")
filehandle.write("# News\n\n")
filehandle.write("# News\n")
for date, commits in self.commit_list.items():
printed_date = False
for commit in commits:
......@@ -102,7 +107,7 @@ class Project:
if tagcount > 1:
filehandle.close()
return
filehandle.write("\n## {}\n\n{}\n\n{}\n\n".format(
filehandle.write("\n\n## {}\n\n{}\n\n{}\n\n".format(
os.path.basename(self.tags[commit.binsha].path),
self.tags[commit.binsha].tag.message.split("\n")[0],
date))
......@@ -111,7 +116,6 @@ class Project:
filehandle.write("{}\n\n".format(date))
printed_date = True
filehandle.write("\t* {}\n".format(headline(commit)))
filehandle.write("\n")
filehandle.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment