Mohammed Naser | 94a8cb9 | 2023-02-19 20:42:58 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Clone the repository in a temporary directory |
| 4 | mkdir -p /tmp/openstack-${1}-${2} |
| 5 | gh repo clone vexxhost/${1} /tmp/openstack-${1}-${2} |
| 6 | |
| 7 | # Switch to the repository |
| 8 | cd /tmp/openstack-${1}-${2} |
| 9 | |
| 10 | # Create a new branch |
| 11 | git checkout -b opendev/${2} |
| 12 | |
| 13 | # Detect the most recent revision of the change |
| 14 | LATEST_REV=$(git ls-remote https://opendev.org/openstack/${1} | grep -E "refs/changes/[[:digit:]]+/${2}/" | sort -t / -k 5 -g | tail -n1 | awk '{print $2}') |
| 15 | |
| 16 | # Cherry-pick the change |
| 17 | git fetch https://review.opendev.org/openstack/${1} ${LATEST_REV} && git cherry-pick FETCH_HEAD |
| 18 | |
| 19 | # Push this branch to the remote |
| 20 | git push -u origin opendev/${2} |
| 21 | |
| 22 | # Create a PR for this change |
| 23 | gh repo set-default vexxhost/${1} |
| 24 | gh pr create \ |
| 25 | --title "$(git show -s --format=%s)" \ |
| 26 | --body "$(git show -s --format=%B)" \ |
| 27 | --base master \ |
| 28 | --head opendev/${2} |