Mohammed Naser | ee6a9e6 | 2023-03-27 22:18:38 +0000 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
| 3 | # Clone the repository in a temporary directory if it doesn't exist |
| 4 | if [ ! -d "/tmp/vexxhost-${1}" ]; then |
| 5 | gh repo clone vexxhost/${1} /tmp/vexxhost-${1} |
| 6 | fi |
| 7 | |
| 8 | # Switch to the repository |
| 9 | cd /tmp/vexxhost-${1} |
| 10 | |
| 11 | # Allow all branches to be rebased |
| 12 | git remote set-branches upstream '*' |
| 13 | git fetch --all |
| 14 | |
| 15 | # Update the repository |
| 16 | git fetch origin |
| 17 | git fetch upstream |
| 18 | |
| 19 | # Loop over all of the upstream branches |
| 20 | for i in $(git branch -r | grep upstream); do |
| 21 | # Extract the branch name |
| 22 | branch=$(echo $i | sed 's/upstream\///g') |
| 23 | |
| 24 | # Checkout the branch from origin if it exists, otherwise create from upstream |
| 25 | if git branch -r | grep -q origin/${branch}; then |
| 26 | git checkout -B ${branch} origin/${branch} |
| 27 | else |
| 28 | git checkout -B ${branch} upstream/${branch} |
| 29 | fi |
| 30 | |
| 31 | # Rebase the branch from the upstream branch |
| 32 | git rebase upstream/${branch} |
| 33 | |
| 34 | # Push this branch to the remote |
| 35 | git push -fu origin ${branch} |
| 36 | done |