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. 8
      functions/github_hash.sh

8
functions/github_hash.sh

@ -14,8 +14,11 @@
# 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)"
if [ -x "${gitcmd}" ]; then
$gitcmd hash-object "${filename}"
else
filesize=$(stat --format='%s' $filename) filesize=$(stat --format='%s' $filename)
if [ "$(tail -c1 $filename)" == "" ]; then if [ "$(tail -c1 $filename)" == "" ]; then
printf "blob %d\0%s\n" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}' printf "blob %d\0%s\n" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
@ -23,6 +26,7 @@ function fn_get_git_hash(){
printf "blob %d\0%s" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}' printf "blob %d\0%s" "${filesize}" "$(cat $filename)" | sha1sum | awk '{print $1}'
fi fi
fi fi
fi
} }
fn_get_github_manifest(){ fn_get_github_manifest(){

Loading…
Cancel
Save