Mohammed Naser | 94a8cb9 | 2023-02-19 20:42:58 +0000 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
| 3 | # Clone the repository in a temporary directory if it doesn't exist |
Mohammed Naser | 2ea922e | 2023-03-01 22:36:23 +0000 | [diff] [blame] | 4 | if [ ! -d "/tmp/vexxhost-${1}" ]; then |
| 5 | gh repo clone vexxhost/${1} /tmp/vexxhost-${1} |
Mohammed Naser | 94a8cb9 | 2023-02-19 20:42:58 +0000 | [diff] [blame] | 6 | fi |
| 7 | |
| 8 | # Switch to the repository |
Mohammed Naser | 2ea922e | 2023-03-01 22:36:23 +0000 | [diff] [blame] | 9 | cd /tmp/vexxhost-${1} |
Mohammed Naser | 94a8cb9 | 2023-02-19 20:42:58 +0000 | [diff] [blame] | 10 | |
| 11 | # Update the repository |
| 12 | git fetch origin |
| 13 | |
| 14 | # Switch to the branch that we're cherry-picking into |
| 15 | git checkout -B backport/${3}/${2} origin/${3} |
| 16 | |
| 17 | # Cherry-pick the change |
| 18 | git cherry-pick -x ${2} |
| 19 | |
| 20 | # Push this branch to the remote |
| 21 | git push -u origin backport/${3}/${2} |
| 22 | |
| 23 | # Create a PR for this change |
| 24 | gh repo set-default vexxhost/${1} |
| 25 | gh 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} |