From 4b60bb76a11b414ccd71a0086ba8140e5ce49da5 Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Fri, 4 Apr 2025 16:36:33 +0200 Subject: [PATCH] helper script to apply a github patch --- scripts/apply_github_patch.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/apply_github_patch.sh diff --git a/scripts/apply_github_patch.sh b/scripts/apply_github_patch.sh new file mode 100755 index 0000000..6bd7c2a --- /dev/null +++ b/scripts/apply_github_patch.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This script applies a patch from a Github URL (commit/PR) to the current path. +# Usage: ./apply_github_patch.sh + +URL=$1 +if [ -z "$URL" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Download the diff file from the URL +DIFF_FILE=$(mktemp) +curl -sL "$URL.diff" > "$DIFF_FILE" +if [ $? -ne 0 ]; then + echo "Failed to download diff from $URL" + exit 1 +fi + +# Apply the patch +git apply "$DIFF_FILE" +if [ $? -ne 0 ]; then + echo "Failed to apply patch from $URL" + rm "$DIFF_FILE" + exit 1 +fi + +echo "Successfully applied patch from $URL" +rm "$DIFF_FILE"