Removing the multiple calls to determine VCS type.

* Credit goes to fidian@rumkin.com
This commit is contained in:
tlimoncelli@stackexchange.com
2015-06-20 19:10:17 +00:00
parent 64e019c8e6
commit efe7bbc8cd

View File

@@ -25,7 +25,7 @@ source "${0%/*}"/_stack_lib.sh
# Set REPOBASE to the top of the repository # Set REPOBASE to the top of the repository
# Set VCS_TYPE to 'git', 'hg', 'svn' or 'unknown' # Set VCS_TYPE to 'git', 'hg', 'svn' or 'unknown'
if git rev-parse --show-toplevel >/dev/null 2>&1 ; then if which >/dev/null 2>/dev/null git && git rev-parse --show-toplevel >/dev/null 2>&1 ; then
VCS_TYPE=git VCS_TYPE=git
REPOBASE=$(git rev-parse --show-toplevel) REPOBASE=$(git rev-parse --show-toplevel)
elif [ -d ".svn" ] ; then elif [ -d ".svn" ] ; then
@@ -39,7 +39,7 @@ elif [ -d ".svn" ] ; then
REPOBASE=$(cd "$parent" ; pwd) REPOBASE=$(cd "$parent" ; pwd)
VCS_TYPE=svn VCS_TYPE=svn
elif hg root >/dev/null 2>&1 ; then elif which >/dev/null 2>/dev/null hg && hg root >/dev/null 2>&1 ; then
# NOTE: hg has to be tested last because it always "succeeds". # NOTE: hg has to be tested last because it always "succeeds".
VCS_TYPE=hg VCS_TYPE=hg
REPOBASE=$(hg root 2>/dev/null) REPOBASE=$(hg root 2>/dev/null)
@@ -240,10 +240,10 @@ function shred_file() {
local OPT local OPT
name="$1" name="$1"
if which shred >/dev/null ; then if which shred >/dev/null 2>/dev/null ; then
CMD=shred CMD=shred
OPT=-u OPT=-u
elif which srm >/dev/null ; then elif which srm >/dev/null 2>/dev/null ; then
#NOTE: srm by default uses 35-pass Gutmann algorithm #NOTE: srm by default uses 35-pass Gutmann algorithm
CMD=srm CMD=srm
OPT=-f OPT=-f