piman@chromium.org | f43d019 | 2010-04-15 02:36:04 +0000 | [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 | |
Raul Tambre | 80ee78e | 2019-05-06 22:41:05 +0000 | [diff] [blame] | 9 | from __future__ import print_function |
| 10 | |
piman@chromium.org | f43d019 | 2010-04-15 02:36:04 +0000 | [diff] [blame] | 11 | import gclient_utils |
| 12 | import optparse |
| 13 | import os |
| 14 | import re |
| 15 | import subprocess |
| 16 | import sys |
| 17 | |
| 18 | |
| 19 | def show_log(path, authors, since='1 week ago'): |
| 20 | """Display log in a single git repo.""" |
| 21 | |
| 22 | author_option = ' '.join(['--author=' + author for author in authors]) |
| 23 | command = ' '.join(['git log', author_option, '--since="%s"' % since, |
| 24 | 'origin/master', '| git shortlog']) |
| 25 | status = subprocess.Popen(['sh', '-c', command], |
| 26 | cwd=path, |
| 27 | stdout=subprocess.PIPE).communicate()[0].rstrip() |
| 28 | |
| 29 | if len(status.splitlines()) > 0: |
Raul Tambre | 80ee78e | 2019-05-06 22:41:05 +0000 | [diff] [blame] | 30 | print('---------- %s ----------' % path) |
| 31 | print(status) |
piman@chromium.org | f43d019 | 2010-04-15 02:36:04 +0000 | [diff] [blame] | 32 | |
| 33 | |
| 34 | def main(): |
| 35 | """Take no arguments.""" |
| 36 | |
| 37 | option_parser = optparse.OptionParser() |
| 38 | option_parser.add_option("-a", "--author", action="append", default=[]) |
| 39 | option_parser.add_option("-s", "--since", default="1 week ago") |
| 40 | options, args = option_parser.parse_args() |
| 41 | |
| 42 | root, entries = gclient_utils.GetGClientRootAndEntries() |
| 43 | |
| 44 | # which entries map to a git repos? |
| 45 | paths = [k for k, v in entries.items() if not re.search('svn', v)] |
| 46 | paths.sort() |
| 47 | |
| 48 | for path in paths: |
| 49 | dir = os.path.normpath(os.path.join(root, path)) |
| 50 | show_log(dir, options.author, options.since) |
| 51 | |
| 52 | |
| 53 | if __name__ == '__main__': |
| 54 | main() |