blob: dc8b8c9d73666c057a9753c30b5601ffe256f08e [file] [log] [blame]
Mike Frysingerf6013762019-06-13 02:30:51 -04001# -*- coding:utf-8 -*-
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07002#
3# Copyright (C) 2008 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Sarah Owenscecd1d82012-11-01 22:59:27 -070017from __future__ import print_function
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070018from color import Coloring
19from command import PagedCommand
20
21class Prune(PagedCommand):
22 common = True
23 helpSummary = "Prune (delete) already merged topics"
24 helpUsage = """
25%prog [<project>...]
26"""
27
28 def Execute(self, opt, args):
David Pursehouse8a68ff92012-09-24 12:15:13 +090029 all_branches = []
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070030 for project in self.GetProjects(args):
David Pursehouse8a68ff92012-09-24 12:15:13 +090031 all_branches.extend(project.PruneHeads())
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070032
David Pursehouse8a68ff92012-09-24 12:15:13 +090033 if not all_branches:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070034 return
35
36 class Report(Coloring):
37 def __init__(self, config):
38 Coloring.__init__(self, config, 'status')
39 self.project = self.printer('header', attr='bold')
40
David Pursehouse8a68ff92012-09-24 12:15:13 +090041 out = Report(all_branches[0].project.config)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070042 out.project('Pending Branches')
43 out.nl()
44
45 project = None
46
David Pursehouse8a68ff92012-09-24 12:15:13 +090047 for branch in all_branches:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070048 if project != branch.project:
49 project = branch.project
50 out.nl()
51 out.project('project %s/' % project.relpath)
52 out.nl()
53
54 commits = branch.commits
55 date = branch.date
Sarah Owenscecd1d82012-11-01 22:59:27 -070056 print('%s %-33s (%2d commit%s, %s)' % (
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070057 branch.name == project.CurrentBranch and '*' or ' ',
58 branch.name,
59 len(commits),
60 len(commits) != 1 and 's' or ' ',
Sarah Owenscecd1d82012-11-01 22:59:27 -070061 date))