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

Side by Side Diff: git-utils/git-tree-prune

Issue 9657005: Added depot_tools/utils, added util to prune dead git branches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 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 | Annotate | Revision Log
« 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')
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 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 """ A tool for listing branches with closed and abandoned issues."""
M-A Ruel 2012/03/15 15:27:13 """A
groby-ooo-7-16 2012/03/19 19:24:49 Done.
7
8 import os
9 import sys
10 import urllib2
11
12 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
13 DEPOT_TOOLS_DIR = os.path.dirname(BASE_DIR)
14 sys.path.insert(0, DEPOT_TOOLS_DIR)
15
16 import git_cl
17
18
19 def get_branches():
20 """Get list of all local git branches."""
21 return [Branch(l[2:]) for l in git_cl.RunGit(["branch"]).splitlines()]
22
M-A Ruel 2012/03/15 15:27:13 2 vertical lines between file level symbols
groby-ooo-7-16 2012/03/19 19:24:49 Done.
23 class Branch(git_cl.Changelist):
24 def __init__(self, name):
25 git_cl.Changelist.__init__(self, branchref=name)
26 self._issue_status = None
27
28 def GetStatus(self):
29 if not self._issue_status:
30 if self.GetIssue():
31 try:
32 issue_properties = self.RpcServer().get_issue_properties(
33 self.GetIssue(), None)
34 if issue_properties['closed']:
35 self._issue_status = 'closed'
36 else:
37 self._issue_status = 'pending'
38 except urllib2.HTTPError, e:
39 if e.code == 404:
40 self._issue_status = 'abandoned'
41 else:
42 self._issue_status = 'no-issue'
43 return self._issue_status
44
45
46 def main(argv):
47 branches = get_branches()
48 filtered = { 'closed' : [],
49 'pending' : [],
50 'abandoned' : [],
51 'no-issue' : []}
52
53 for branch in branches:
54 filtered[branch.GetStatus()].append(branch)
55
56 print "# Branches with closed issues"
57 for branch in filtered['closed']:
58 print "git branch -D %s # Issue %s is closed." % (branch.GetBranch(),
59 branch.GetIssue())
60
61 print "\n# Pending Branches"
62 for branch in filtered['pending']:
63 print "# Branch %s - Issue %s" % (branch.GetBranch(), branch.GetIssue())
64
65 print "\n# Branches with abandoned issues"
66 for branch in filtered['abandoned']:
67 print "# Branch %s - was issue %s" % (
68 branch.GetBranch(), branch.GetIssue())
69
70 print "\n# Branches without associated issues"
71 for branch in filtered['no-issue']:
72 print "# Branch %s" % (branch.GetBranch())
73
74 return 0
75
76
77 if __name__ == '__main__':
78 sys.exit(main(sys.argv[1:]))
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