| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| garciadeblas | 3c25fab | 2019-11-18 17:24:43 +0100 | [diff] [blame^] | 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 15 | |
| 16 | |
| 17 | GIT() { |
| garciadeblas | e460692 | 2017-01-04 14:28:04 +0100 | [diff] [blame] | 18 | CMD git "$@" |
| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | |
| 22 | OSM_git_checkout() { |
| 23 | |
| 24 | # Updates all the branches in the local repo (clones if it does not exist) |
| 25 | if [ -d $OSM_MDG ]; then |
| 26 | INFO "reusing existing workspace" |
| 27 | cd $OSM_MDG |
| garciadeblas | 1e9eff6 | 2017-03-15 10:23:03 +0100 | [diff] [blame] | 28 | GIT fetch --all --tags |
| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 29 | #git checkout master #to make sure that we are in the right branch before pulling the code |
| 30 | #git pull |
| 31 | else |
| 32 | INFO "cloning MDG $OSM_MDG from $OSM_GIT_URL/$OSM_MDG" |
| 33 | GIT clone $OSM_GIT_URL/$OSM_MDG |
| 34 | cd $OSM_MDG |
| garciadeblas | e460692 | 2017-01-04 14:28:04 +0100 | [diff] [blame] | 35 | for remote in `git branch -r |grep -v /HEAD`; do GIT branch --track ${remote#origin/} $remote; done |
| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 36 | fi |
| 37 | |
| 38 | if [ $# -gt 0 ]; then |
| 39 | if [ "$1" = "checkout" ]; then |
| 40 | INFO "Code to compile: '$2'" |
| 41 | GIT checkout $2 |
| 42 | else |
| 43 | INFO "Code to compile: gerrit refspec '$1', commit-id: '$2'" |
| 44 | GIT fetch origin $1 || FATAL "git fetch origin '$1' didn't work" |
| 45 | GIT checkout -f $2 || FATAL "git checkout -f '$2' didn't work" |
| 46 | fi |
| 47 | else |
| 48 | INFO "Code to compile: master" |
| 49 | GIT checkout master |
| 50 | fi |
| 51 | |
| 52 | } |
| garciadeblas | e460692 | 2017-01-04 14:28:04 +0100 | [diff] [blame] | 53 | |