blob: b4fce7ab55fb324a4702b4df1d4e07d1955b82a6 [file] [log] [blame]
Mohammed Naseree6a9e62023-03-27 22:18:38 +00001#!/bin/bash -xe
2
3# Clone the repository in a temporary directory if it doesn't exist
4if [ ! -d "/tmp/vexxhost-${1}" ]; then
5 gh repo clone vexxhost/${1} /tmp/vexxhost-${1}
6fi
7
8# Switch to the repository
9cd /tmp/vexxhost-${1}
10
11# Allow all branches to be rebased
12git remote set-branches upstream '*'
13git fetch --all
14
15# Update the repository
16git fetch origin
17git fetch upstream
18
19# Loop over all of the upstream branches
20for 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}
36done