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 | 508d090e463e15da3e5db17b0a4a04cab167aeba (patch) | |
| tree | 50856c0751bfc278277c09718d07c6eecfb292c0 /openstack/common/setup.py | |
| parent | a9e10729737c33a4c29c409ec966ce64301383c7 (diff) | |
| download | oslo-508d090e463e15da3e5db17b0a4a04cab167aeba.tar.gz oslo-508d090e463e15da3e5db17b0a4a04cab167aeba.tar.xz oslo-508d090e463e15da3e5db17b0a4a04cab167aeba.zip | |
Add git changelog method.
Change-Id: I71d99f00b2154bf151a1521016118ba6bd088f79
Diffstat (limited to 'openstack/common/setup.py')
| -rw-r--r-- | openstack/common/setup.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/openstack/common/setup.py b/openstack/common/setup.py index 34c88e5..9eabfcc 100644 --- a/openstack/common/setup.py +++ b/openstack/common/setup.py @@ -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)) |
