Commit f43d019e authored by piman@chromium.org's avatar piman@chromium.org

Adding weekly tool to help with weekly snippets

This tool displays all checkins by one (or several) authors in the past week (or configurable time), in all dependencies. Only works on git dependencies currently.

Review URL: http://codereview.chromium.org/1602020

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@44612 0039d316-1c4b-4281-b951-d872f2087c98
parent 57564661
......@@ -323,3 +323,33 @@ def PathDifference(root, subpath):
# provided.
root = os.path.join(root, '')
return subpath[len(root):]
def FindFileUpwards(filename, path=None):
"""Search upwards from the a directory (default: current) to find a file."""
if not path:
path = os.getcwd()
path = os.path.realpath(path)
while True:
file_path = os.path.join(path, filename)
if os.path.isfile(file_path):
return file_path
(new_path, _) = os.path.split(path)
if new_path == path:
return None
path = new_path
def GetGClientRootAndEntries(path=None):
"""Returns the gclient root and the dict of entries."""
config_file = '.gclient_entries'
config_path = FindFileUpwards(config_file, path)
if not config_path:
print "Can't find", config_file
return None
env = {}
execfile(config_path, env)
config_dir = os.path.dirname(config_path)
return config_dir, env['entries']
#!/usr/bin/env python
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Display log of checkins of one particular developer since a particular
date. Only works on git dependencies at the moment."""
import gclient_utils
import optparse
import os
import re
import subprocess
import sys
def show_log(path, authors, since='1 week ago'):
"""Display log in a single git repo."""
author_option = ' '.join(['--author=' + author for author in authors])
command = ' '.join(['git log', author_option, '--since="%s"' % since,
'origin/master', '| git shortlog'])
status = subprocess.Popen(['sh', '-c', command],
cwd=path,
stdout=subprocess.PIPE).communicate()[0].rstrip()
if len(status.splitlines()) > 0:
print '---------- %s ----------' % path
print status
def main():
"""Take no arguments."""
option_parser = optparse.OptionParser()
option_parser.add_option("-a", "--author", action="append", default=[])
option_parser.add_option("-s", "--since", default="1 week ago")
options, args = option_parser.parse_args()
root, entries = gclient_utils.GetGClientRootAndEntries()
# which entries map to a git repos?
paths = [k for k, v in entries.items() if not re.search('svn', v)]
paths.sort()
for path in paths:
dir = os.path.normpath(os.path.join(root, path))
show_log(dir, options.author, options.since)
if __name__ == '__main__':
main()
......@@ -5,6 +5,7 @@
"""Display active git branches and code changes in a chromiumos workspace."""
import gclient_utils
import os
import re
import subprocess
......@@ -51,15 +52,6 @@ def show_dir(full_name, relative_name, color):
print status
def find_file(filename):
"""Search upwards from the current directory to find a file."""
path = filename
while os.getcwd().split('/'):
if os.path.isfile(path):
return path
path = os.path.join('../', path)
def main():
"""Take no arguments."""
......@@ -69,23 +61,14 @@ def main():
color = True
base = os.path.basename(os.getcwd())
config_file = '.gclient_entries'
config_path = find_file(config_file)
if not config_path:
print "Can't find", config_file
sys.exit(1)
env = {}
execfile(config_path, env)
root, entries = gclient_utils.GetGClientRootAndEntries()
# which are the git repos?
raw = [k for k, v in env['entries'].items() if not re.search('svn', v)]
# which entries map to a git repos?
raw = [k for k, v in entries.items() if not re.search('svn', v)]
raw.sort()
# We want to use the full path for testing, but we want to use the relative
# path for display.
root = os.path.dirname(config_path)
fulldirs = map(lambda(p): os.path.normpath(os.path.join(root, p)), raw)
reldirs = map(lambda(p): re.sub('^' + base, '.', p), raw)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment