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

Side by Side Diff: wtf

Issue 1324003: Add wtf tool to provide a quick summary of pending changes. (Closed)
Patch Set: Final tweaks. Created 10 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 active git branches and code changes in a chromiumos workspace."""
7
8 import os
9 import re
10 import subprocess
11 import sys
12
13
14 def show_dir(full_name, relative_name, color):
15 """Display active work in a single git repo."""
16
17 def show_name():
18 """Display the directory name."""
19
20 if color:
21 sys.stdout.write('========= %s[44m%s[37m%s%s[0m ========\n' %
22 (chr(27), chr(27), relative_name, chr(27)))
23 else:
24 sys.stdout.write('========= %s ========\n' % relative_name)
25
26 lines_printed = 0
27
28 cmd = ['git', 'branch', '-v']
29 if color:
30 cmd.append('--color')
31
32 branch = subprocess.Popen(cmd,
33 cwd=full_name,
34 stdout=subprocess.PIPE).communicate()[0].rstrip()
35
36 if len(branch.splitlines()) > 1:
37 if lines_printed == 0:
38 show_name()
39 lines_printed += 1
40 print branch
41
42 status = subprocess.Popen(['git', 'status'],
43 cwd=full_name,
44 stdout=subprocess.PIPE).communicate()[0].rstrip()
45
46 if len(status.splitlines()) > 2:
47 if lines_printed == 0:
48 show_name()
49 if lines_printed == 1:
50 print '---------------'
51 print status
52
53
54 def find_file(filename):
55 """Search upwards from the current directory to find a file."""
56 path = filename
57 while os.getcwd().split('/'):
58 if os.path.isfile(path):
59 return path
60 path = os.path.join('../', path)
61
62
63 def main():
64 """Take no arguments."""
65
66 color = False
67
68 if os.isatty(1):
69 color = True
70
71 base = os.path.basename(os.getcwd())
72 config_file = '.gclient_entries'
73 config_path = find_file(config_file)
74
75 if not config_path:
76 print "Can't find", config_file
77 sys.exit(1)
78
79 env = {}
80 execfile(config_path, env)
81
82 # which are the git repos?
83 raw = [k for k, v in env['entries'].items() if not re.search('svn', v)]
84 raw.sort()
85
86 # We want to use the full path for testing, but we want to use the relative
87 # path for display.
88 root = os.path.dirname(config_path)
89 fulldirs = map(lambda(p): os.path.normpath(os.path.join(root, p)), raw)
90 reldirs = map(lambda(p): re.sub('^' + base, '.', p), raw)
91
92 for full_path, relative_path in zip(fulldirs, reldirs):
93 show_dir(full_path, relative_path, color)
94
95 if __name__ == '__main__':
96 main()
OLDNEW
« 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