<commit_before>#!/bin/sh
# This is a hack to import from a branch and call it a versioned snapshot.

OUTDIR=v1.0
REPORT_TAG=v1.0.1
BRANCH=release-1.0

set -e
set -x

tmpdir=docs.$RANDOM

echo fetching upstream
git fetch upstream
go build ./_tools/release_docs
./release_docs --branch ${BRANCH} --output-dir $tmpdir >/dev/null
rm ./release_docs

echo removing old
git rm -rf ${OUTDIR}/docs/ ${OUTDIR}/examples/ > /dev/null
rm -rf ${OUTDIR}/docs/ ${OUTDIR}/examples/

echo adding new
mv $tmpdir/docs ${OUTDIR}
mv $tmpdir/examples ${OUTDIR}
git add ${OUTDIR}/docs/ ${OUTDIR}/examples/ > /dev/null
rmdir $tmpdir

echo stripping
for dir in docs examples; do
    find ${OUTDIR}/${dir} -type f -name \*.md | while read X; do
        sed -i \
            -e '/<!-- BEGIN STRIP_FOR_RELEASE.*/,/<!-- END STRIP_FOR_RELEASE.*/d' \
            -e "s|releases.k8s.io/HEAD|releases.k8s.io/${REPORT_TAG}|g" \
            ${X}
    done
    git stage ${OUTDIR}/${dir}
done

git status
<commit_msg>Use BSD compatible sed argument.<commit_after>#!/bin/sh
# This is a hack to import from a branch and call it a versioned snapshot.

OUTDIR=v1.0
REPORT_TAG=v1.0.1
BRANCH=release-1.0

set -e
set -x

tmpdir=docs.$RANDOM

echo fetching upstream
git fetch upstream
go build ./_tools/release_docs
./release_docs --branch ${BRANCH} --output-dir $tmpdir >/dev/null
rm ./release_docs

echo removing old
git rm -rf ${OUTDIR}/docs/ ${OUTDIR}/examples/ > /dev/null
rm -rf ${OUTDIR}/docs/ ${OUTDIR}/examples/

echo adding new
mv $tmpdir/docs ${OUTDIR}
mv $tmpdir/examples ${OUTDIR}
git add ${OUTDIR}/docs/ ${OUTDIR}/examples/ > /dev/null
rmdir $tmpdir

echo stripping
for dir in docs examples; do
    find ${OUTDIR}/${dir} -type f -name \*.md | while read X; do
        sed -i .import_docs_tmp \
            -e '/<!-- BEGIN STRIP_FOR_RELEASE.*/,/<!-- END STRIP_FOR_RELEASE.*/d' \
            -e "s|releases.k8s.io/HEAD|releases.k8s.io/${REPORT_TAG}|g" \
            ${X}
    done
    rm $(find ${OUTDIR}/${dir} -name \*.import_docs_tmp)
    git stage ${OUTDIR}/${dir}
done

git status

{'fraction_non_alphanumeric': 0.15797172111165286, 'fraction_numerical': 0.008776206728425159, 'mean_word_length': 2.9385796545105567, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3354164', 'n_tokens_mistral': 781, 'n_tokens_neox': 752, 'n_words': 220}