1
1
#! /bin/bash
2
+
3
+ set -e -o pipefail -x
4
+
2
5
PYVER=$( scripts/getpyver.py short)
3
6
if [[ " $1 " == " check" ]]; then
4
7
echo -e " \033[36m>> Downloading baseline for $PYVER ...\033[0m"
@@ -19,8 +22,38 @@ rm "pages/creating-a-theme.rst" "pages/extending.rst" "pages/internals.rst" "pag
19
22
LC_ALL=' en_US.UTF-8' PYTHONHASHSEED=0 nikola build --invariant
20
23
if [[ " $1 " == " check" ]]; then
21
24
echo -e " \033[36m>> Testing baseline...\033[0m"
22
- diff -ubwr ../baseline output
23
- if [[ $? == 0 ]]; then
25
+ python3 -c '
26
+ # In-place edit of copyright notes to adjust the copyright year.
27
+ import time
28
+ YEAR = str(time.gmtime().tm_year)
29
+ for edit_me in [
30
+ "../baseline/rss.xml",
31
+ "../baseline/index.html",
32
+ "../baseline/galleries/index.html",
33
+ "../baseline/galleries/demo/index.html",
34
+ "../baseline/listings/index.html",
35
+ "../baseline/listings/hello.py.html",
36
+ "../baseline/listings/__pycache__/index.html",
37
+ "../baseline/pages/about-nikola/index.html",
38
+ "../baseline/pages/bootstrap-demo/index.html",
39
+ "../baseline/pages/dr-nikolas-vendetta/index.html",
40
+ "../baseline/pages/listings-demo/index.html",
41
+ "../baseline/pages/quickref/index.html",
42
+ "../baseline/pages/quickstart/index.html",
43
+ "../baseline/posts/welcome-to-nikola/index.html",
44
+ ]:
45
+ with open(edit_me, "rt+") as rssf:
46
+ rss = rssf.read()
47
+ copyright_prelude = "Contents © "
48
+ copyright_prelude_position = rss.find(copyright_prelude)
49
+ if -1 == copyright_prelude_position:
50
+ raise RuntimeError(f"Could not find copyright note in {edit_me}")
51
+ copyright_position = copyright_prelude_position + len(copyright_prelude)
52
+ new_rss = rss[:copyright_position] + YEAR + rss[copyright_position+4:]
53
+ rssf.seek(0, 0)
54
+ rssf.write(new_rss)
55
+ '
56
+ if diff -ubwr ../baseline output; then
24
57
echo -e " \033[32;1m>> Baseline test successful\033[0m"
25
58
else
26
59
CODE=$?
0 commit comments