File Coverage

blib/lib/App/Git/Workflow/Brs.pm
Criterion Covered Total %
statement 32 38 84.2
branch 2 6 33.3
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 44 54 81.4


line stmt bran cond sub pod time code
1              
2             # Created on: 2019-04-20 08:37:44
3             # Create by: Ivan Wills
4             # $Id$
5             # $Revision$, $HeadURL$, $Date$
6             # $Revision$, $Source$, $Date$
7              
8             use strict;
9 4     4   1165 use warnings;
  4         8  
  4         100  
10 4     4   17 use version;
  4         7  
  4         77  
11 4     4   16 use Carp;
  4         6  
  4         30  
12 4     4   233 use English qw/ -no_match_vars /;
  4         6  
  4         215  
13 4     4   18 use base 'App::Git::Workflow';
  4         7  
  4         19  
14 4     4   1160  
  4         8  
  4         1660  
15             our $VERSION = version->new(1.1.19);
16              
17             my ($self) = @_;
18             my $git_dir = $self->git->rev_parse("--show-toplevel");
19 3     3 1 9 chomp $git_dir;
20 3         35 my $brs = "$git_dir/$self->{GIT_DIR}/brs";
21 3         9  
22 3         14 if ( ! -f $brs ) {
23             return;
24 3 50       58 }
25 3         22  
26             open my $fh, '<', $brs or die "Could not open '$brs': $!\n";
27             my @branches = map {/^(.*?)\n\Z/; $1} <$fh>;
28 0 0       0 close $fh;
29 0         0  
  0         0  
  0         0  
30 0         0 return @branches;
31             }
32 0         0  
33             my ($self, @branches) = @_;
34              
35             my $git_dir = $self->git->rev_parse("--show-toplevel");
36 1     1 1 4 chomp $git_dir;
37             my $brs = "$git_dir/$self->{GIT_DIR}/brs";
38 1         3 open my $fh, '>', $brs or die "Could not open '$brs' for writing: $!\n";
39 1         3 print {$fh} map {"$_\n"} @branches;
40 1         3 }
41 1 50       85  
42 1         3 1;
  1         4  
  1         10  
43              
44              
45             =head1 NAME
46              
47             App::Git::Workflow::Brs - Common methods for branch stack operations
48              
49             =head1 VERSION
50              
51             This documentation refers to App::Git::Workflow::Brs version 0.0.1
52              
53             =head1 SYNOPSIS
54              
55             use App::Git::Workflow::Brs;
56              
57             # Brief but working code example(s) here showing the most common usage(s)
58             # This section will be as far as many users bother reading, so make it as
59             # educational and exemplary as possible.
60              
61              
62             =head1 DESCRIPTION
63              
64             =head1 SUBROUTINES/METHODS
65              
66             =head2 C<get_brs ()>
67              
68             Gets the current branch stack
69              
70             =head2 C<set_brs ( @branches )>
71              
72             Sets the new branch stack
73              
74             =head1 DIAGNOSTICS
75              
76             =head1 CONFIGURATION AND ENVIRONMENT
77              
78             =head1 DEPENDENCIES
79              
80             =head1 INCOMPATIBILITIES
81              
82             =head1 BUGS AND LIMITATIONS
83              
84             There are no known bugs in this module.
85              
86             Please report problems to Ivan Wills (ivan.wills@gmail.com).
87              
88             Patches are welcome.
89              
90             =head1 AUTHOR
91              
92             Ivan Wills - (ivan.wills@gmail.com)
93              
94             =head1 LICENSE AND COPYRIGHT
95              
96             Copyright (c) 2019 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
97             All rights reserved.
98              
99             This module is free software; you can redistribute it and/or modify it under
100             the same terms as Perl itself. See L<perlartistic>. This program is
101             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
102             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
103             PARTICULAR PURPOSE.
104              
105             =cut