Created
April 20, 2017 14:28
-
-
Save petdance/7c44793015b58c110a75c7b75f4d49b6 to your computer and use it in GitHub Desktop.
dirty, a shell script for showing modified files whether under Git or Subversion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
# Try Git. | |
my @lines = qx{git diff --name-only 2> /dev/null}; | |
if ( $? == 0 ) { | |
print for @lines; | |
exit 0; | |
} | |
# Try Subversion. | |
@lines = qx/svn status 2>&1/; | |
exit if @lines == 0; | |
chomp @lines; | |
my $first = $lines[0]; | |
if ( $first !~ /svn: warning: .+ not a working copy/ ) { | |
@lines = grep { !/^[?D]/ } @lines; # Ignore unversioned and deleted files | |
s/^........// for @lines; | |
print "$_\n" for @lines; | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment