2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 # This script requires the user running the script to have "Create References"
13 # permission in Gerrit for the "stable/RELEASE" branch. Where RELEASE is an
14 # official OpenDaylight release. Eg. Oxygen, Nitrogen, Carbon, etc...
18 # 1) Creates a new branch stable/RELEASE (where release is a ODL release,
19 # eg Oxygen, Nitrogen, Carbon, etc...)
20 # 2) Updates .gitreview in the new stable/RELEASE branch to set the
21 # defaultbranch to the new branch.
23 # Required Parameters:
24 # RELEASE: The name of the release to create a branch for.
26 mkdir -p "$WORKSPACE/archives"
27 LOG_FILE="$WORKSPACE/archives/branch-cut.log"
32 if [ -z "$RELEASE" ]; then
33 echo "ERROR: RELEASE variable must be set to a release name. Eg Carbon"
37 git config gitreview.username jenkins-releng
38 git submodule foreach git review -s
41 # --- Start create new maintenance branch
42 echo "---> Creating new mainenance branch"
43 git submodule foreach git fetch origin
45 git submodule foreach git checkout -b "stable/${RELEASE,,}" origin/master
46 git checkout -b "stable/${RELEASE,,}" origin/master
53 echo "---> Verify maintenance branch"
54 git submodule foreach git branch
56 } | tee -a "$LOG_FILE"
62 if [ "$DRY_RUN" = false ]
64 echo "Pushing stable/${RELEASE,,} branches to Gerrit"
65 git submodule foreach git push gerrit "stable/${RELEASE,,}"
66 git push gerrit "stable/$RELEASE"
68 # --- End create new maintenance branch
70 # --- Start update .gitreview
71 echo "---> Update .gitreview"
72 git submodule foreach sed -i -e "s#defaultbranch=master#defaultbranch=stable/${RELEASE,,}#" .gitreview
73 git submodule foreach git add .gitreview
74 git submodule foreach "git commit -sm 'Update .gitreview to stable/${RELEASE,,}'"
75 sed -i -e "s#defaultbranch=master#defaultbranch=stable/${RELEASE,,}#" .gitreview
77 git commit -sm "Update .gitreview to stable/${RELEASE,,}"
79 # Generate git patches
80 patch_dir="$WORKSPACE/archives/patches/git-review"
82 for module in $(git submodule | awk '{ print $2 }')
85 git format-patch --stdout "origin/master" > "$patch_dir/${module//\//-}.patch"
86 git bundle create "$patch_dir/${module//\//-}.bundle" "origin/master..HEAD"
95 echo "---> Verify .gitreview"
96 git submodule foreach git show HEAD
98 git submodule foreach git log --oneline -2 --graph --decorate
99 git log --oneline -2 --graph --decorate
100 } | tee -a "$LOG_FILE"
106 if [ "$DRY_RUN" = false ]
108 echo "Pushing .gitreview patches to Gerrit"
109 git submodule foreach git review -t "branch-cut-${RELEASE,,}"
110 git review -t "branch-cut-${RELEASE,,}"
112 # --- Stop update .gitreview