blob: c3445b79e3ad4257ccddc5a55aa12e58b97b61fb [file] [log] [blame]
Mohammed Naser94a8cb92023-02-19 20:42:58 +00001#!/bin/bash
2
3# Clone the repository in a temporary directory
4mkdir -p /tmp/openstack-${1}-${2}
5gh repo clone vexxhost/${1} /tmp/openstack-${1}-${2}
6
7# Switch to the repository
8cd /tmp/openstack-${1}-${2}
9
10# Create a new branch
11git checkout -b opendev/${2}
12
13# Detect the most recent revision of the change
14LATEST_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
17git fetch https://review.opendev.org/openstack/${1} ${LATEST_REV} && git cherry-pick FETCH_HEAD
18
19# Push this branch to the remote
20git push -u origin opendev/${2}
21
22# Create a PR for this change
23gh repo set-default vexxhost/${1}
24gh pr create \
25 --title "$(git show -s --format=%s)" \
26 --body "$(git show -s --format=%B)" \
27 --base master \
28 --head opendev/${2}