Skip to content

Commit 9cfe256

Browse files
committed
Version checker
1 parent 79e0919 commit 9cfe256

File tree

8 files changed

+1015
-3
lines changed

8 files changed

+1015
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ Thumbs.db
5252
dist/
5353
build/
5454
*.egg-info/
55+
static/version.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ curl -X POST "http://localhost:8000/admin/weekly-summary/trigger"
541541
or for a specific week:
542542

543543
```bash
544-
curl -X POST "http://10.0.0.181:8000/admin/weekly-summary/trigger" \
544+
curl -X POST "http://localhost:8000/admin/weekly-summary/trigger" \
545545
-H "Content-Type: application/json" \
546546
-d '{"date": "2026-02-06"}'
547547
```

generate_version.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Generate version.json with git hash and timestamp.
4+
5+
This file is used by the frontend to detect when a new version is deployed.
6+
"""
7+
8+
import json
9+
import subprocess
10+
from datetime import datetime, timezone
11+
from pathlib import Path
12+
13+
14+
def get_git_hash() -> str:
15+
"""Get the current git commit hash."""
16+
try:
17+
result = subprocess.run(
18+
["git", "rev-parse", "HEAD"],
19+
capture_output=True,
20+
text=True,
21+
check=True,
22+
)
23+
return result.stdout.strip()
24+
except subprocess.CalledProcessError:
25+
return "unknown"
26+
27+
28+
def get_git_branch() -> str:
29+
"""Get the current git branch name."""
30+
try:
31+
result = subprocess.run(
32+
["git", "rev-parse", "--abbrev-ref", "HEAD"],
33+
capture_output=True,
34+
text=True,
35+
check=True,
36+
)
37+
return result.stdout.strip()
38+
except subprocess.CalledProcessError:
39+
return "unknown"
40+
41+
42+
def generate_version_file() -> None:
43+
"""Generate static/version.json with current git info."""
44+
version_data = {
45+
"hash": get_git_hash(),
46+
"branch": get_git_branch(),
47+
"timestamp": datetime.now(timezone.utc).isoformat(),
48+
}
49+
50+
# Write to static directory
51+
static_dir = Path(__file__).parent / "static"
52+
static_dir.mkdir(exist_ok=True)
53+
54+
version_file = static_dir / "version.json"
55+
with open(version_file, "w") as f:
56+
json.dump(version_data, f, indent=2)
57+
58+
print(f"✅ Generated {version_file}")
59+
print(f" Hash: {version_data['hash'][:8]}")
60+
print(f" Branch: {version_data['branch']}")
61+
print(f" Timestamp: {version_data['timestamp']}")
62+
63+
64+
if __name__ == "__main__":
65+
generate_version_file()

0 commit comments

Comments
 (0)