Skip to content

Commit 0181415

Browse files
twieckiferrine
andauthored
Add script to downstream PRs. (#39)
Co-authored-by: Maxim Kochurov <maxim.v.kochurov@gmail.com>
1 parent 1b76af3 commit 0181415

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

bin/downstream_pr.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ]
4+
then
5+
echo "Usage: downstream_pr.sh <PR_number>"
6+
echo "Port a specified PR from the Aesara repo to the PyTensor repo. Will create a new branch, adapt and apply the upstream PR, and create a new PR to PyTensor."
7+
exit 1
8+
fi
9+
10+
set -e
11+
12+
git checkout main
13+
git pull origin main
14+
git checkout -b downstream_$1
15+
16+
echo "Downloading patch..."
17+
wget -O $1.patch https://patch-diff.githubusercontent.com/raw/aesara-devs/aesara/pull/$1.patch
18+
19+
echo "Replacing aesara strings..."
20+
declare -a replace_strings=(
21+
"s/aesara/pytensor/g"
22+
"s/Aesara/PyTensor/g"
23+
)
24+
25+
for replace in "${replace_strings[@]}"; do
26+
sed -i -e "$replace" $1.patch
27+
done
28+
29+
echo "Applying patch..."
30+
if git am -3 --reject $1.patch ; then
31+
echo "Patch applied successfully..."
32+
else
33+
echo "Patch failed. Find the .rej file and apply the changes manually. Then 'git add' all changed files, followed by 'git am --continue'. Then create a PR manually."
34+
exit 1
35+
fi
36+
37+
echo "Running pre-commit"
38+
pre-commit run --all
39+
40+
git push origin downstream_$1
41+
# get the informative title
42+
title=$(curl https://api.github.com/repos/aesara-devs/aesara/pulls/$1 2>/dev/null | jq '.title')
43+
gh pr create --repo pymc-devs/pytensor --title "Downstreaming Aesara PR $1: $title" --body "Downstreaming https://github.com/aesara-devs/aesara/pull/$1. PR port done by downstream_pr.sh script."

0 commit comments

Comments
 (0)