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