blob: e90ff21379f7ff95f7587c2e2aae54e5806734f1 [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
David Pursehouse819827a2020-02-12 15:20:19 +090021
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070022class Prune(PagedCommand):
23 common = True
24 helpSummary = "Prune (delete) already merged topics"
25 helpUsage = """
26%prog [<project>...]
27"""
28
29 def Execute(self, opt, args):
David Pursehouse8a68ff92012-09-24 12:15:13 +090030 all_branches = []
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070031 for project in self.GetProjects(args):
David Pursehouse8a68ff92012-09-24 12:15:13 +090032 all_branches.extend(project.PruneHeads())
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070033
David Pursehouse8a68ff92012-09-24 12:15:13 +090034 if not all_branches:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070035 return
36
37 class Report(Coloring):
38 def __init__(self, config):
39 Coloring.__init__(self, config, 'status')
40 self.project = self.printer('header', attr='bold')
41
David Pursehouse8a68ff92012-09-24 12:15:13 +090042 out = Report(all_branches[0].project.config)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070043 out.project('Pending Branches')
44 out.nl()
45
46 project = None
47
David Pursehouse8a68ff92012-09-24 12:15:13 +090048 for branch in all_branches:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070049 if project != branch.project:
50 project = branch.project
51 out.nl()
52 out.project('project %s/' % project.relpath)
53 out.nl()
54
Mike Frysinger6da17752019-09-11 18:43:17 -040055 print('%s %-33s ' % (
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070056 branch.name == project.CurrentBranch and '*' or ' ',
Mike Frysinger6da17752019-09-11 18:43:17 -040057 branch.name), end='')
58
59 if not branch.base_exists:
60 print('(ignoring: tracking branch is gone: %s)' % (branch.base,))
61 else:
62 commits = branch.commits
63 date = branch.date
64 print('(%2d commit%s, %s)' % (
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070065 len(commits),
66 len(commits) != 1 and 's' or ' ',
Sarah Owenscecd1d82012-11-01 22:59:27 -070067 date))