@@ -746,6 +746,24 @@ function git_fetch_helper() {
746
746
git fetch " $git_url " " $@ " || die " git fetch failed"
747
747
}
748
748
749
+ #
750
+ # Run git fetch with the passed arguments. Git url must be passed as first
751
+ # argument. If FETCH_GIT_TOKEN is set and this is a github repository
752
+ # then pass-in the token when fetching.
753
+ #
754
+ function git_branch_exists() {
755
+ local git_url=" $1 "
756
+ local label=' '
757
+ shift
758
+
759
+ if [[ -n " $FETCH_GIT_TOKEN " ]] &&
760
+ [[ " $git_url " == https://github.com/* ]]; then
761
+ git_url=" ${git_url/ https: \/\/ / https: \/\/ ${FETCH_GIT_TOKEN} @ } "
762
+ label=' [token passed]'
763
+ fi
764
+ git fetch " $git_url " " $@ " --no-tags --depth=1 || return 1
765
+ }
766
+
749
767
#
750
768
# Fetch package repository into $WORKDIR/repo
751
769
#
@@ -769,6 +787,25 @@ function fetch_repo_from_git() {
769
787
logmust git show-ref repo-HEAD
770
788
logmust git show-ref upstream-HEAD
771
789
else
790
+
791
+ #
792
+ # The "os-upgrade" branch is used for Ubuntu version upgrade projects. As such, the following
793
+ # block of code will only be executed if the `PACKAGE_GIT_BRANCH` is set to "os-upgrade". Not
794
+ # all product repositories are required to have an "os-upgrade" branch, because some packages
795
+ # will successfully build on the new Ubuntu version as well as the old without any changes.
796
+ # To allow engineering to create the "os-upgrade" branch only in repositories that require
797
+ # changes for the new Ubuntu version, this block of code will check if the "os-upgrade" branch
798
+ # exists in the repository and if it does not, it will build off of "develop" instead.
799
+ #
800
+ if [[ " $PACKAGE_GIT_BRANCH " == " os-upgrade" ]]; then
801
+ git_branch_exists " $PACKAGE_GIT_URL " " $PACKAGE_GIT_BRANCH "
802
+ branch_exists=$?
803
+ if [[ $branch_exists -ne 0 ]]; then
804
+ echo " NOTE: The branch 'os-upgrade' does not exist for this repo. Using 'develop' instead."
805
+ PACKAGE_GIT_BRANCH=" develop"
806
+ fi
807
+ fi
808
+
772
809
logmust git_fetch_helper " $PACKAGE_GIT_URL " --no-tags \
773
810
" +$PACKAGE_GIT_BRANCH :repo-HEAD" --depth=1
774
811
logmust git show-ref repo-HEAD
0 commit comments