blob: 4dfdd397d6445c614d7e3b739f875ea78008756f [file] [log] [blame]
Mohammed Naser94a8cb92023-02-19 20:42:58 +00001#!/bin/bash -xe
2
3# Clone the repository in a temporary directory if it doesn't exist
Mohammed Naser2ea922e2023-03-01 22:36:23 +00004if [ ! -d "/tmp/vexxhost-${1}" ]; then
5 gh repo clone vexxhost/${1} /tmp/vexxhost-${1}
Mohammed Naser94a8cb92023-02-19 20:42:58 +00006fi
7
8# Switch to the repository
Mohammed Naser2ea922e2023-03-01 22:36:23 +00009cd /tmp/vexxhost-${1}
Mohammed Naser94a8cb92023-02-19 20:42:58 +000010
11# Update the repository
12git fetch origin
13
14# Switch to the branch that we're cherry-picking into
15git checkout -B backport/${3}/${2} origin/${3}
16
17# Cherry-pick the change
18git cherry-pick -x ${2}
19
20# Push this branch to the remote
21git push -u origin backport/${3}/${2}
22
23# Create a PR for this change
24gh repo set-default vexxhost/${1}
25gh pr create \
26 --title "[${3}] $(git show -s --format=%s)" \
27 --body "$(git show -s --format=%B)" \
28 --base ${3} \
29 --head backport/${3}/${2}