Test separated ots hooks
This commit is contained in:
parent
094cd53864
commit
6dc8399238
11 changed files with 386 additions and 13 deletions
49
hooks/post-commit-node
Executable file
49
hooks/post-commit-node
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
# Git OpenTimestamp Post-Commit Hook (Node.js version)
|
||||
# Requires: @opentimestamps/ots (npm install)
|
||||
|
||||
set -e
|
||||
|
||||
OUTPUT_DIR=".ots"
|
||||
OUTPUT_FILE="$OUTPUT_DIR/proof.ots"
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
COMMIT_HASH=$(git rev-parse HEAD)
|
||||
|
||||
# Generate proof using Node.js
|
||||
node -e "
|
||||
const ots = require('@opentimestamps/ots');
|
||||
const fs = require('fs');
|
||||
const hash = '$COMMIT_HASH';
|
||||
const output = '$OUTPUT_FILE';
|
||||
const hashBuffer = Buffer.from(hash, 'hex');
|
||||
|
||||
ots.Timestamp.hash(hashBuffer).then(timestamp => {
|
||||
// Note: This creates a local proof only, not submitted to calendars
|
||||
// For full Bitcoin attestation, use the ots CLI version
|
||||
const proof = {
|
||||
hash: hash,
|
||||
timestamp: new Date().toISOString(),
|
||||
status: 'pending',
|
||||
note: 'Local proof only - use ots CLI for calendar submission'
|
||||
};
|
||||
fs.writeFileSync(output, JSON.stringify(proof, null, 2));
|
||||
console.log('[ots-node] Generated local proof: ' + hash.substring(0, 8));
|
||||
}).catch(err => {
|
||||
console.error('[ots-node] Error:', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
"
|
||||
|
||||
# Save previous commit for chaining
|
||||
PREV_COMMIT=$(git rev-parse HEAD^1 2>/dev/null || echo "")
|
||||
if [ -n "$PREV_COMMIT" ]; then
|
||||
echo "$PREV_COMMIT" > "$OUTPUT_DIR/prev-commit.txt"
|
||||
fi
|
||||
|
||||
# Create individual proof file (JSON format for node version)
|
||||
INDIVIDUAL_PROOF="$OUTPUT_DIR/${COMMIT_HASH}.ots"
|
||||
cp "$OUTPUT_FILE" "$INDIVIDUAL_PROOF"
|
||||
|
||||
echo "[ots-node] Proof generated successfully"
|
||||
Loading…
Add table
Add a link
Reference in a new issue