[email protected] | f43d019 | 2010-04-15 02:36:04 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Display log of checkins of one particular developer since a particular |
| 7 | date. Only works on git dependencies at the moment.""" |
| 8 | |
| 9 | import gclient_utils |
| 10 | import optparse |
| 11 | import os |
| 12 | import re |
| 13 | import subprocess |
| 14 | import sys |
| 15 | |
| 16 | |
| 17 | def show_log(path, authors, since='1 week ago'): |
| 18 | """Display log in a single git repo.""" |
| 19 | |
| 20 | author_option = ' '.join(['--author=' + author for author in authors]) |
| 21 | command = ' '.join(['git log', author_option, '--since="%s"' % since, |
| 22 | 'origin/master', '| git shortlog']) |
| 23 | status = subprocess.Popen(['sh', '-c', command], |
| 24 | cwd=path, |
| 25 | stdout=subprocess.PIPE).communicate()[0].rstrip() |
| 26 | |
| 27 | if len(status.splitlines()) > 0: |
| 28 | print '---------- %s ----------' % path |
| 29 | print status |
| 30 | |
| 31 | |
| 32 | def main(): |
| 33 | """Take no arguments.""" |
| 34 | |
| 35 | option_parser = optparse.OptionParser() |
| 36 | option_parser.add_option("-a", "--author", action="append", default=[]) |
| 37 | option_parser.add_option("-s", "--since", default="1 week ago") |
| 38 | options, args = option_parser.parse_args() |
| 39 | |
| 40 | root, entries = gclient_utils.GetGClientRootAndEntries() |
| 41 | |
| 42 | # which entries map to a git repos? |
| 43 | paths = [k for k, v in entries.items() if not re.search('svn', v)] |
| 44 | paths.sort() |
| 45 | |
| 46 | for path in paths: |
| 47 | dir = os.path.normpath(os.path.join(root, path)) |
| 48 | show_log(dir, options.author, options.since) |
| 49 | |
| 50 | |
| 51 | if __name__ == '__main__': |
| 52 | main() |