diff options
author | Monty Taylor <mordred@inaugust.com> | 2012-02-07 10:02:45 -0800 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2012-02-09 10:29:16 -0800 |
commit | 2a6be979018944a2e7dc27cdbb71f682c6874bfe (patch) | |
tree | c351e7a68732c70956aaa0ed79c271d85865efbc /setup.py | |
parent | 225107526bf157d5034bfe72e4c2b76ee20b6212 (diff) | |
download | pbr-2a6be979018944a2e7dc27cdbb71f682c6874bfe.tar.gz |
Add git changelog method.
Change-Id: I71d99f00b2154bf151a1521016118ba6bd088f79
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -36,10 +36,13 @@ def parse_mailmap(mailmap='.mailmap'): return mapping -def str_dict_replace(s, mapping): - for s1, s2 in mapping.iteritems(): - s = s.replace(s1, s2) - return s +def canonicalize_emails(changelog, mapping): + """ Takes in a string and an email alias mapping and replaces all + instances of the aliases in the string with their real email + """ + for alias, email in mapping.iteritems(): + changelog = changelog.replace(alias, email) + return changelog # Get requirements from the first file that exists @@ -112,3 +115,13 @@ version_info = { 'revno': %s } """ % (branch_nick, revid, revno)) + + +def write_git_changelog(): + """ Write a changelog based on the git changelog """ + if os.path.isdir('.git'): + git_log_cmd = 'git log --stat' + changelog = _run_shell_command(git_log_cmd) + mailmap = parse_mailmap() + with open("ChangeLog", "w") as changelog_file: + changelog_file.write(canonicalize_emails(changelog, mailmap)) |