Skip to content

Instantly share code, notes, and snippets.

@Ic3fr0g
Created June 26, 2019 09:06
Show Gist options
  • Save Ic3fr0g/3f4d98fd4a1593bac1dce9e84e7de849 to your computer and use it in GitHub Desktop.
Save Ic3fr0g/3f4d98fd4a1593bac1dce9e84e7de849 to your computer and use it in GitHub Desktop.
CHANGELOG with tag annotations
import os
import re
import string
# Prerequisites:
#
# github_changelog_generator repo -t token --date-format '%Y-%m-%d %H:%M' -o 'CHANGELOG.md'
# git tag -l -n9 > a.txt
# All tags should be of type 'v\d[\.\w]*'
if __name__ == '__main__':
with open('a.txt', 'r') as foo:
data = foo.readlines()
foo.close()
tags_title_annotation = {}
matched = None
for line in data:
if re.search('v\d[\.\w]*', line):
matched = re.findall('v\d[\.\w]*', line)[0]
tags_title_annotation[matched] = {
'title': '',
'annotation': []
}
title = line.replace(matched, '').strip()
title = title[0].upper() + title[1:]
tags_title_annotation[matched]['title'] = title
elif matched is not None:
line = line.strip()
annotation = line.replace(matched, '')
tags_title_annotation[matched]['annotation'].append(annotation)
with open('CHANGELOG.md', 'r') as fil:
data = fil.readlines()
fil.close()
matched = None
data_w = data
for index, line in enumerate(data):
if re.search('## \[v\d[\.\w]*\]', line):
matched = re.findall('v\d[\.\w]*', line)[0]
insert_data = [
"**Description:**",
tags_title_annotation[matched]['title']
]
values = "\n" + \
"\n".join(insert_data) + \
"\n" + \
"\n".join(tags_title_annotation[matched]['annotation']) + \
"\n"
data_w.insert(index + 1, values)
with open('CHANGELOG.md', 'w') as fin:
fin.writelines(data_w)
fin.close()
@Ic3fr0g
Copy link
Author

Ic3fr0g commented Jun 26, 2019

Sample

## [v1.7.5g](https://github.com) (2019-06-22 15:55)

**Description:**
Minor patch fix in clustering

- Small changes to Clustering when no txns take place.
- Checks are now in place for nan(s) in sql insert statement.
- This was happening in the case of IH where no txns were taking place and hence elasticity was not calculable.
[Full Changelog](https://github.com)

**Merged pull requests:**
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment