7 # When the GERRIT_BRANCH is not set the rebase job wasn't triggered by merge
8 # but it's executed as part of timer. In this case we will make sure that all
9 # branches from remote are synced with Nordix Gerrit.
10 if [[ -z "${GERRIT_BRANCH:-}" ]] ; then
11 echo "-- Fetch all branches from OpenDev for project: ${PROJECT} --"
12 REMOTE_BRANCHES=$(git branch -r | grep -v 'HEAD -> ' | awk '/origin/ {gsub("origin/","");print}')
13 for branch in ${REMOTE_BRANCHES} ; do
14 git branch -f --track ${branch} origin/${branch}
16 # The job was triggered by merge on OpenDev. We will make sure that branch set
17 # in GERRIT_BRANCH is in sync with Nordix Gerrit.
19 echo "-- Fetch branch: ${GERRIT_BRANCH} from OpenDev for project: ${PROJECT} --"
20 REMOTE_BRANCHES=${GERRIT_BRANCH}
21 git branch -f --track ${GERRIT_BRANCH} origin/${GERRIT_BRANCH}
24 echo "-- Adding new remote $NORDIX_REMOTE for sync --"
25 git remote add nordix $NORDIX_REMOTE
27 echo "-- Merging changes from OpenDev remote branches to local branch: --"
28 for branch in ${REMOTE_BRANCHES} ; do
29 echo "------ Branch name: ${branch}"
30 git checkout ${branch} -q
31 git merge origin/${branch} --ff-only --stat
33 echo "-- Pushing changes to Nordix Gerrit --"
34 git push nordix --all -v
35 echo "--------------------------------------------------------------------"
36 # Make sure the Nordix is set from Jenkins Job configuration
37 # parameter: NORDIX_REMOTE in next job run
38 if git remote | grep nordix > /dev/null ; then