Use strings not unicode in changelog generator
[mudpy.git] / bin / git2gch
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """Generates potential ChangeLog file contents from commit messages."""
4
5 # Copyright (c) 2010-2011 Jeremy Stanley <fungi@yuggoth.org>. Permission
6 # to use, copy, modify, and distribute this software is granted under
7 # terms provided in the LICENSE file distributed with this software.
8
9 # needs GitPython: http://gitorious.org/git-python
10 import git
11 import time
12
13 copyright = """\
14 Copyright (c) 2004-2010 Jeremy Stanley <fungi@yuggoth.org>. Permission to
15 use, copy, modify, and distribute this software is granted under terms
16 provided in the LICENSE file distributed with this software.
17
18 """
19
20 emacsinfo = "\f" + """
21 Local Variables:
22 mode: change-log
23 coding: utf-8
24 left-margin: 8
25 fill-column: 76
26 version-control: never
27 End:\
28 """
29
30 generated = ""
31 for commit in git.Repo().log():
32     header = "%s  %s  <%s>" % (
33         time.strftime("%Y-%m-%d %H:%M:%S UTC", commit.authored_date),
34         commit.author.name,
35         commit.author.email
36     )
37     comments = ""
38     for line in commit.message.split("\n")[1:]:
39         if line:
40             line = "\t%s" % line
41         if line.startswith("\t*"):
42             line = "\n%s" % line
43         comments += "%s\n" % line
44     generated += "%s\n%s\n" % (header, comments)
45 print("%s%s%s" % (generated, copyright, emacsinfo))