-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_to_.git_hooks_pre-commit
More file actions
35 lines (25 loc) · 1.06 KB
/
copy_to_.git_hooks_pre-commit
File metadata and controls
35 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#
# Pre-commit hook to update the baseline build timestamp
# This ensures every commit updates the BuildInfo.BUILD_TIMESTAMP constant
# so deployed applications can be tracked to specific baseline versions.
#
set -e
BUILD_INFO_FILE="src/main/java/dev/abstratium/core/BuildInfo.java"
# Check if the BuildInfo file exists
if [ ! -f "$BUILD_INFO_FILE" ]; then
echo "Warning: $BUILD_INFO_FILE not found, skipping timestamp update"
exit 0
fi
# Generate current UTC timestamp in ISO-8601 format (second granularity)
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "Updating baseline build timestamp to: $TIMESTAMP"
# Update the BUILD_TIMESTAMP constant in BuildInfo.java
# This uses sed to replace the timestamp value while preserving the rest of the file
sed -i.bak "s/BUILD_TIMESTAMP = \"[^\"]*\"/BUILD_TIMESTAMP = \"$TIMESTAMP\"/" "$BUILD_INFO_FILE"
# Remove backup file created by sed
rm -f "${BUILD_INFO_FILE}.bak"
# Stage the updated file so it's included in this commit
git add "$BUILD_INFO_FILE"
echo "✅ Baseline build timestamp updated and staged"
exit 0