Commit 97639acd authored by Brad King's avatar Brad King

pre-commit: Add support for ExternalData SHA512 objects

parent af5b350a
...@@ -16,6 +16,7 @@ ExternalData_stage_linked_content() { ...@@ -16,6 +16,7 @@ ExternalData_stage_linked_content() {
# Identify the hash algorithm used. # Identify the hash algorithm used.
case "$file" in case "$file" in
*.md5) algo=MD5 ; base="${file/.md5}" ; validate="^[0-9a-fA-F]{32}$" ;; *.md5) algo=MD5 ; base="${file/.md5}" ; validate="^[0-9a-fA-F]{32}$" ;;
*.sha512) algo=SHA512 ; base="${file/.sha512}" ; validate="^[0-9a-fA-F]{128}$" ;;
*) die "$file: invalid content link (unrecognized extension)" ;; *) die "$file: invalid content link (unrecognized extension)" ;;
esac esac
...@@ -62,7 +63,7 @@ ExternalData_stage_linked_content() { ...@@ -62,7 +63,7 @@ ExternalData_stage_linked_content() {
ExternalData_non_content_link() { ExternalData_non_content_link() {
# Reject simultaneous raw file and content link. # Reject simultaneous raw file and content link.
files=$(git ls-files -- "$file.md5") files=$(git ls-files -- "$file.md5" "$file.sha512")
if test -n "$files"; then if test -n "$files"; then
die "$file: file may not coexist with $files" die "$file: file may not coexist with $files"
fi fi
...@@ -89,7 +90,7 @@ ExternalData_STORE=".ExternalData" ...@@ -89,7 +90,7 @@ ExternalData_STORE=".ExternalData"
# Process content links created by/for the CMake ExternalData module. # Process content links created by/for the CMake ExternalData module.
git diff-index --cached HEAD --diff-filter=AM | git diff-index --cached HEAD --diff-filter=AM |
while read src_mode dst_mode src_obj dst_obj status file; do while read src_mode dst_mode src_obj dst_obj status file; do
if echo "$dst_mode $file" | egrep_q '^100644 .*\.(md5)$'; then if echo "$dst_mode $file" | egrep_q '^100644 .*\.(md5|sha512)$'; then
ExternalData_stage_linked_content ExternalData_stage_linked_content
else else
ExternalData_non_content_link ExternalData_non_content_link
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment