#!/bin/sh

dst=$(dirname $0)
tmp=$dst/tmp
pwd=$(pwd)
if [ -z "$1" ]; then
  echo "Error: No version supplied"
  exit 1
fi
branch="release-$1"
echo "branch is ${branch}"


git clone --depth 1 -b $branch git@github.com:pingcap/docs $tmp/docs
dict_commit=$(cd $tmp/docs && git rev-parse HEAD && cd $pwd)
echo "dict commit is ${dict_commit}"
rm -rf $dst/docs
mkdir $dst/docs
cp $tmp/docs/pd-configuration-file.md $dst/docs/pd-configuration-file.md
cp $tmp/docs/tidb-configuration-file.md $dst/docs/tidb-configuration-file.md
cp $tmp/docs/tiflash/tiflash-configuration.md $dst/docs/tiflash-configuration-file.md
cp $tmp/docs/tikv-configuration-file.md $dst/docs/tikv-configuration-file.md
cp $tmp/docs/dynamic-config.md $dst/docs/dynamic-config.md
echo "v$1" > $dst/docs/version

rm -rf $tmp