Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: host/willis

Issue 6412001: Add support for showing the last weeks activity to Willis. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/dev-util.git@master
Patch Set: Changes remaining after splitting original CL into three CLs. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: host/willis
diff --git a/host/willis b/host/willis
index 72868192ef7ba68e45c7b70c3c0cf2ffacb58982..c1a08e95e7794eff5093a6caf0df0e4713a99373 100755
--- a/host/willis
+++ b/host/willis
@@ -5,6 +5,7 @@
"""Display active git branches and code changes in a ChromiumOS workspace."""
+import optparse
import os
import re
import subprocess
@@ -66,19 +67,40 @@ def GetStatus(full_name, relative_name, color):
return RunCommand(full_name, command).splitlines()
-def ShowDir(full_name, relative_name, color):
+def GetHistory(full_name, relative_name, color, author, days):
+ """Return a list of oneline log messages.
+
+ The messages are for the author going back a specified number of days.
+ """
+
+ command = ['git', 'log',
+ '--author=' + author,
+ '--after=' + '-' + str(days) + 'days',
+ '--pretty=oneline',
+ 'm/master']
+
+ return RunCommand(full_name, command).splitlines()
+
+
+def ShowDir(full_name, relative_name, color, logs, author, days):
"""Display active work in a single git repository."""
branches = GetBranches(full_name, relative_name, color)
status = GetStatus(full_name, relative_name, color)
- if branches or status:
+ if logs:
+ history = GetHistory(full_name, relative_name, color, author, days)
+ else:
+ history = []
+
+ if branches or status or history:
ShowName(relative_name, color)
if branches: print '\n'.join(branches)
if status: print '\n'.join(status)
+ if history: print '\n'.join(history)
- if branches or status:
+ if branches or status or history:
print ""
@@ -95,7 +117,29 @@ def FindRoot():
def main():
- """Take no arguments."""
+ parser = optparse.OptionParser(usage = 'usage: %prog [options]\n')
+
+ parser.add_option('-l', '--logs', default=False,
+ help='Show the last few days of your commits in short '
+ 'form.',
+ action='store_true',
+ dest='logs')
+
+ parser.add_option('-d', '--days', default=8,
+ help='Set the number of days of history to show.',
+ type='int',
+ dest='days')
+
+ parser.add_option('-a', '--author', default=os.environ['USER'],
+ help='Set the author to filter for.',
+ type='string',
+ dest='author')
+
+ options, arguments = parser.parse_args()
+
+ if arguments:
+ parser.print_usage()
+ return 1
color = os.isatty(1)
root = FindRoot()
@@ -106,7 +150,7 @@ def main():
reldirs = [re.sub('^' + re.escape(root) + '/', '', p) for p in repos]
for full, relative in zip(repos, reldirs):
- ShowDir(full, relative, color)
+ ShowDir(full, relative, color, options.logs, options.author, options.days)
if __name__ == '__main__':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698