commit
bc5fbd6ba9
180 files changed
+63750
No files matched your search
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
REMOTE="upstream-oxi"
|
||||
COMMIT="${1:-}"
|
||||
|
||||
if [ -z "$COMMIT" ]; then
|
||||
echo "usage: $0 <oxi-commit>" >&2
|
||||
exit 2
|
||||
fi
|
||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
echo "error: not a Git checkout" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||
echo "error: working tree must be clean before porting an Oxi commit" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! git remote get-url "$REMOTE" >/dev/null 2>&1; then
|
||||
echo "error: Oxi remote is not configured; run ./scripts/setup-upstream.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fetch "$REMOTE" --tags >/dev/null
|
||||
SHA="$(git rev-parse "$COMMIT^{commit}")"
|
||||
PARENT="$(git rev-parse "$SHA^1")"
|
||||
branch="port/oxi-${SHA:0:12}"
|
||||
git switch -c "$branch"
|
||||
|
||||
tmp_raw="$(mktemp)"
|
||||
tmp_mapped="$(mktemp)"
|
||||
cleanup() { rm -f "$tmp_raw" "$tmp_mapped"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
git diff --binary --find-renames "$PARENT..$SHA" -- backend/ > "$tmp_raw"
|
||||
sed \
|
||||
-e 's#^diff --git a/backend/#diff --git a/#' \
|
||||
-e 's# b/backend/# b/#' \
|
||||
-e 's#^--- a/backend/#--- a/#' \
|
||||
-e 's#^+++ b/backend/#+++ b/#' \
|
||||
-e 's#^rename from backend/#rename from #' \
|
||||
-e 's#^rename to backend/#rename to #' \
|
||||
-e 's#^copy from backend/#copy from #' \
|
||||
-e 's#^copy to backend/#copy to #' \
|
||||
-e 's#^Binary files a/backend/#Binary files a/#' \
|
||||
-e 's# and b/backend/# and b/#' \
|
||||
"$tmp_raw" > "$tmp_mapped"
|
||||
|
||||
if [ ! -s "$tmp_mapped" ]; then
|
||||
echo "Oxi commit $SHA has no backend/ changes to map."
|
||||
else
|
||||
git apply --3way --index "$tmp_mapped"
|
||||
fi
|
||||
|
||||
printf 'Ported backend portion of Oxi commit %s onto branch %s.\n' "$SHA" "$branch"
|
||||
printf 'UPSTREAM_BASE was intentionally NOT changed.\n'
|
||||
printf 'Review the original commit, especially frontend changes: git show %s -- frontend/\n' "$SHA"
|
||||
Reference in new issue
Block a user