Browse Source

Stopped trying to do my own hashing and rely on Git for now

pull/553/head
Jared Ballou 10 years ago
parent
commit
a0e37297a9
  1. 16
      functions/github_hash.sh

16
functions/github_hash.sh

@ -14,13 +14,17 @@
# Calculate the Git hash for a file # Calculate the Git hash for a file
function fn_get_git_hash(){ function fn_get_git_hash(){
filename=$1 filename=$1
if [ -e $filename ] if [ -e $filename ]; then
then gitcmd="$(which git)"
filesize=$(stat --format='%s' $filename) if [ -x "${gitcmd}" ]; then
if [ "$(tail -c1 $filename)" == "" ]; then $gitcmd hash-object "${filename}"
printf "blob %d\0%s\n" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
else else
printf "blob %d\0%s" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}' filesize=$(stat --format='%s' $filename)
if [ "$(tail -c1 $filename)" == "" ]; then
printf "blob %d\0%s\n" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
else
printf "blob %d\0%s" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
fi
fi fi
fi fi
} }

Loading…
Cancel
Save