diff --git a/.gitignore b/.gitignore index dad1f96a1f..e17d71bfd6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,10 @@ tmp/ cache/ output/ +baseline/ +nikola-baseline-build/ /tags +v3.*.zip.* # GitHub token .pypt/gh-token diff --git a/scripts/baseline.sh b/scripts/baseline.sh index 8fb13e814e..7cb99cdcab 100755 --- a/scripts/baseline.sh +++ b/scripts/baseline.sh @@ -1,4 +1,7 @@ #!/bin/bash + +set -e -o pipefail -x + PYVER=$(scripts/getpyver.py short) if [[ "$1" == "check" ]]; then echo -e "\033[36m>> Downloading baseline for $PYVER...\033[0m" @@ -19,6 +22,35 @@ rm "pages/creating-a-theme.rst" "pages/extending.rst" "pages/internals.rst" "pag LC_ALL='en_US.UTF-8' PYTHONHASHSEED=0 nikola build --invariant if [[ "$1" == "check" ]]; then echo -e "\033[36m>> Testing baseline...\033[0m" + python3 -c ' +# In-place edit of copyright notes to adjust the copyright year. +for edit_me in [ + "../baseline/rss.xml", + "../baseline/index.html", + "../baseline/galleries/index.html", + "../baseline/galleries/demo/index.html", + "../baseline/listings/index.html", + "../baseline/listings/hello.py.html", + "../baseline/listings/__pycache__/index.html", + "../baseline/pages/about-nikola/index.html", + "../baseline/pages/bootstrap-demo/index.html", + "../baseline/pages/dr-nikolas-vendetta/index.html", + "../baseline/pages/listings-demo/index.html", + "../baseline/pages/quickref/index.html", + "../baseline/pages/quickstart/index.html", + "../baseline/posts/welcome-to-nikola/index.html", + ]: + with open(edit_me, "rt+") as rssf: + rss = rssf.read() + copyright_prelude = "Contents © " + copyright_prelude_position = rss.find(copyright_prelude) + if -1 == copyright_prelude_position: + raise RuntimeError(f"Could not find copyright note in {edit_me}") + copyright_position = copyright_prelude_position + len(copyright_prelude) + new_rss = rss[:copyright_position] + "2024" + rss[copyright_position+4:] + rssf.seek(0, 0) + rssf.write(new_rss) + ' diff -ubwr ../baseline output if [[ $? == 0 ]]; then echo -e "\033[32;1m>> Baseline test successful\033[0m"