File Coverage

blib/lib/Group/Git/Cmd/TagList.pm
Criterion Covered Total %
statement 24 53 45.2
branch 0 12 0.0
condition n/a
subroutine 8 10 80.0
pod 2 2 100.0
total 34 77 44.1


line stmt bran cond sub pod time code
1             package Group::Git::Cmd::TagList;
2              
3             # Created on: 2013-05-06 21:57:07
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   899 use Moo::Role;
  1         3  
  1         12  
10 1     1   2681 use strict;
  1         3  
  1         21  
11 1     1   4 use warnings;
  1         2  
  1         29  
12 1     1   6 use version;
  1         3  
  1         9  
13 1     1   73 use Carp;
  1         2  
  1         93  
14 1     1   8 use English qw/ -no_match_vars /;
  1         2  
  1         9  
15 1     1   411 use File::chdir;
  1         3  
  1         85  
16 1     1   8 use Getopt::Alt;
  1         2  
  1         21  
17              
18             our $VERSION = version->new('0.7.5');
19              
20             requires 'repos';
21             requires 'verbose';
22              
23             my $opt = Getopt::Alt->new(
24             { help => __PACKAGE__, },
25             [
26             'verbose|v+',
27             'count|c',
28             ]
29             );
30              
31             sub tag_list_start {
32 0     0 1   my ($self) = @_;
33 0           my ($conf) = $self->conf;
34 0           my $out = '';
35              
36 0           local $ARGV;
37 0           $opt->process;
38              
39 0 0         return if $opt->opt->verbose;
40              
41             # repository server generated tags aren't available until repos is called
42             # so we call it here.
43 0           $self->repos;
44              
45 0           for my $tag (sort keys %{ $conf->{tags} }) {
  0            
46 0 0         my $count = $opt->opt->count ? ' (' . @{ $conf->{tags}{$tag} } . ')' : '';
  0            
47 0           $out .= "$tag$count\n";
48 0 0         if ($opt->opt->verbose) {
49 0           for my $repo (sort @{ $conf->{tags}{$tag} }) {
  0            
50 0           $out .= " $repo\n";
51             }
52             }
53             }
54              
55 0           return $out;
56             }
57              
58             sub tag_list {
59 0     0 1   my ($self, $name) = @_;
60 0           my ($conf) = $self->conf;
61 0 0         return unless -d $name;
62              
63 0 0         return if ! $opt->opt->verbose;
64              
65 0           my $out = '';
66 0           for my $tag (sort keys %{ $conf->{tags} }) {
  0            
67 0 0         if ( grep {/^$name$/} @{ $conf->{tags}{$tag} } ) {
  0            
  0            
68 0           $out .= " $tag\n";
69             }
70             }
71              
72 0           return $out;
73             }
74              
75             1;
76              
77             __END__
78              
79             =head1 NAME
80              
81             Group::Git::Cmd::TagList - Runs git status on a git project
82              
83             =head1 VERSION
84              
85             This documentation refers to Group::Git::Cmd::TagList version 0.7.5.
86              
87             =head1 SYNOPSIS
88              
89             grou-git tag-list [-v|--verbose] [-c|--count]
90             grou-git tag-list --help
91             grou-git tag-list --man
92             grou-git tag-list --version
93              
94             Options:
95             -c --count Show a count of repositories in each tag
96             -v --verbose Show the repositories in each tag
97             --help Show the help information
98             --man Show full documentation
99             --version Show the version information
100              
101             =head1 DESCRIPTION
102              
103             =head1 SUBROUTINES/METHODS
104              
105             =over 4
106              
107             =item C<tag_list_start ()>
108              
109             Returns the list of all defined tags and if in verbose mode the repositories
110             who have that tag.
111              
112             =item C<tag_list ($name)>
113              
114             Does nothing.
115              
116             =back
117              
118             =head1 DIAGNOSTICS
119              
120             =head1 CONFIGURATION AND ENVIRONMENT
121              
122             =head1 DEPENDENCIES
123              
124             =head1 INCOMPATIBILITIES
125              
126             =head1 BUGS AND LIMITATIONS
127              
128             There are no known bugs in this module.
129              
130             Please report problems to Ivan Wills (ivan.wills@gmail.com).
131              
132             Patches are welcome.
133              
134             =head1 AUTHOR
135              
136             Ivan Wills - (ivan.wills@gmail.com)
137              
138             =head1 LICENSE AND COPYRIGHT
139              
140             Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
141             All rights reserved.
142              
143             This module is free software; you can redistribute it and/or modify it under
144             the same terms as Perl itself. See L<perlartistic>. This program is
145             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
146             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
147             PARTICULAR PURPOSE.
148              
149             =cut