(refs #35) fix dependent scheduler re-checking: make calculation of upstream lazier
[buildbot.git] / contrib / generate_changelog.py
blobbff73892471e8f153c9af5b88180d648bf13a62b
1 #!/usr/bin/env python
3 # Copyright 2008
4 # Steve 'Ashcrow' Milner <smilner+buildbot@redhat.com>
6 # This software may be freely redistributed under the terms of the GNU
7 # general public license.
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software
11 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
12 """
13 Generates changelog information using git.
14 """
16 __docformat__ = 'restructuredtext'
19 import os
20 import sys
23 def print_err(msg):
24 """
25 Wrapper to make printing to stderr nicer.
27 :Parameters:
28 - `msg`: the message to print.
29 """
30 sys.stderr.write(msg)
31 sys.stderr.write('\n')
34 def usage():
35 """
36 Prints out usage information to stderr.
37 """
38 print_err('Usage: %s git-binary since' % sys.argv[0])
39 print_err(('Example: %s /usr/bin/git f5067523dfae9c7cdefc82'
40 '8721ec593ac7be62db' % sys.argv[0]))
43 def main(args):
44 """
45 Main entry point.
47 :Parameters:
48 - `args`: same as sys.argv[1:]
49 """
50 # Make sure we have the arguments we need, else show usage
51 try:
52 git_bin = args[0]
53 since = args[1]
54 except IndexError, ie:
55 usage()
56 return 1
58 if not os.access(git_bin, os.X_OK):
59 print_err('Can not access %s' % git_bin)
60 return 1
62 # Open a pipe and force the format
63 pipe = os.popen((git_bin + ' log --pretty="format:%ad %ae%n'
64 ' * %s" ' + since + '..'))
65 print pipe.read()
66 pipe.close()
67 return 0
70 if __name__ == '__main__':
71 raise SystemExit(main(sys.argv[1:]))