Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/port-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -euo pipefail

# navigate to the repository root
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."

STABLE_DIR="docs/stable"
PREVIEW_DIR="docs/preview"
PATCH_FILE="/tmp/commit.patch"

if [ $# -lt 1 ]; then
echo "Usage: scripts/apply_patch.sh COMMIT_HASH"
exit 1
fi

COMMIT_HASH=$1

cd "${STABLE_DIR}"
git format-patch -1 ${COMMIT_HASH} --stdout > "${PATCH_FILE}"

# change stable to preview, both in filenames and in file content
sed -i.bkp "s#${STABLE_DIR}#${PREVIEW_DIR}#g" ${PATCH_FILE}

git apply "${PATCH_FILE}" && echo "Patch applied to ${PREVIEW_DIR}." || {
echo "Failed to apply patch."
exit 1
}