File Coverage

blib/lib/App/Git/Workflow/Command/Cows.pm
Criterion Covered Total %
statement 38 38 100.0
branch 4 4 100.0
condition n/a
subroutine 10 10 100.0
pod 1 1 100.0
total 53 53 100.0


line stmt bran cond sub pod time code
1              
2             # Created on: 2014-03-11 20:58:59
3             # Create by: Ivan Wills
4             # $Id$
5             # $Revision$, $HeadURL$, $Date$
6             # $Revision$, $Source$, $Date$
7              
8             use strict;
9 2     2   85298 use warnings;
  2         12  
  2         47  
10 2     2   9 use version;
  2         3  
  2         42  
11 2     2   358 use Getopt::Long;
  2         1439  
  2         10  
12 2     2   684 use Pod::Usage ();
  2         9656  
  2         12  
13 2     2   1104 use Data::Dumper qw/Dumper/;
  2         76456  
  2         57  
14 2     2   560 use English qw/ -no_match_vars /;
  2         4606  
  2         134  
15 2     2   463 use App::Git::Workflow;
  2         2638  
  2         13  
16 2     2   994 use App::Git::Workflow::Command qw/get_options/;
  2         5  
  2         89  
17 2     2   424  
  2         4  
  2         505  
18             our $VERSION = version->new(1.1.20);
19             our $workflow = App::Git::Workflow->new;
20             our ($name) = $PROGRAM_NAME =~ m{^.*/(.*?)$}mxs;
21             our %option;
22              
23             get_options(
24             \%option,
25 2     2 1 10 'quiet|q',
26             );
27              
28             my @files = map { /^#\s+modified:\s+(.*)\n/ }
29             grep {/^#\s+modified:\s+/ }
30 4         14 $workflow->git->status;
31 2         12  
  4         14  
32             for my $file (@files) {
33             my $diff = $workflow->git->diff('--ignore-all-space', $file);
34 2         6 chomp $diff;
35 4         11  
36 4         8 if ( !$diff ) {
37             warn "\t$file\n" unless $option{quiet};
38 4 100       8 $workflow->git->checkout($file);
39 2 100       59 }
40 2         9 }
41              
42             return;
43             }
44 2         7  
45             1;
46              
47              
48             =head1 NAME
49              
50             git-cows - checkout whitespace only changed files
51              
52             =head1 VERSION
53              
54             This documentation refers to git-cows version 1.1.20
55              
56             =head1 SYNOPSIS
57              
58             git-cows [option]
59              
60             OPTIONS:
61             -q --quiet Suppress notifying of files changed
62              
63             -v --verbose Show more detailed option
64             --version Prints the version information
65             --help Prints this help information
66             --man Prints the full documentation for git-cows
67              
68             =head1 DESCRIPTION
69              
70             C<git-cows> resets any files that only contain whitespace changes.
71             This is done by finding all files modified (as shown by a C<git status>) and
72             run them through C<git diff -w>. If any file results in no out put is shown
73             (i.e. the changes are only white spaces) the file is then C<git checkout>ed to
74             remove those changes.
75              
76             This makes it easier make your commits clean of pointless whitespace only
77             changes and makes others work easier.
78              
79             =head1 SUBROUTINES/METHODS
80              
81             =head2 C<run ()>
82              
83             Executes the git workflow command
84              
85             =head1 DIAGNOSTICS
86              
87             =head1 CONFIGURATION AND ENVIRONMENT
88              
89             =head1 DEPENDENCIES
90              
91             =head1 INCOMPATIBILITIES
92              
93             =head1 BUGS AND LIMITATIONS
94              
95             There are no known bugs in this module.
96              
97             Please report problems to Ivan Wills (ivan.wills@gmail.com).
98              
99             Patches are welcome.
100              
101             =head1 AUTHOR
102              
103             Ivan Wills - (ivan.wills@gmail.com)
104              
105             =head1 LICENSE AND COPYRIGHT
106              
107             Copyright (c) 2014 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
108             All rights reserved.
109              
110             This module is free software; you can redistribute it and/or modify it under
111             the same terms as Perl itself. See L<perlartistic>. This program is
112             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
113             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
114             PARTICULAR PURPOSE.
115              
116             =cut