summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2012-02-07 10:02:45 -0800
committerMonty Taylor <mordred@inaugust.com>2012-02-09 10:29:16 -0800
commit2a6be979018944a2e7dc27cdbb71f682c6874bfe (patch)
treec351e7a68732c70956aaa0ed79c271d85865efbc /setup.py
parent225107526bf157d5034bfe72e4c2b76ee20b6212 (diff)
downloadpbr-2a6be979018944a2e7dc27cdbb71f682c6874bfe.tar.gz
Add git changelog method.
Change-Id: I71d99f00b2154bf151a1521016118ba6bd088f79
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index 34c88e5..9eabfcc 100644
--- a/setup.py
+++ b/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))