| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | GIT() { |
| garciadeblas | e460692 | 2017-01-04 14:28:04 +0100 | [diff] [blame] | 5 | CMD git "$@" |
| Jeremy Mordkoff | 35d6f24 | 2016-10-06 16:17:05 -0700 | [diff] [blame] | 6 | } |
| 7 | |
| 8 | |
| 9 | OSM_git_checkout() { |
| 10 | |
| 11 | # Updates all the branches in the local repo (clones if it does not exist) |
| 12 | if [ -d $OSM_MDG ]; then |
| 13 | INFO "reusing existing workspace" |
| 14 | cd $OSM_MDG |
| 15 | GIT pull --all |
| 16 | #git checkout master #to make sure that we are in the right branch before pulling the code |
| 17 | #git pull |
| 18 | else |
| 19 | INFO "cloning MDG $OSM_MDG from $OSM_GIT_URL/$OSM_MDG" |
| 20 | GIT clone $OSM_GIT_URL/$OSM_MDG |
| 21 | cd $OSM_MDG |
| garciadeblas | e460692 | 2017-01-04 14:28:04 +0100 | [diff] [blame] | 22 | 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] | 23 | fi |
| 24 | |
| 25 | if [ $# -gt 0 ]; then |
| 26 | if [ "$1" = "checkout" ]; then |
| 27 | INFO "Code to compile: '$2'" |
| 28 | GIT checkout $2 |
| 29 | else |
| 30 | INFO "Code to compile: gerrit refspec '$1', commit-id: '$2'" |
| 31 | GIT fetch origin $1 || FATAL "git fetch origin '$1' didn't work" |
| 32 | GIT checkout -f $2 || FATAL "git checkout -f '$2' didn't work" |
| 33 | fi |
| 34 | else |
| 35 | INFO "Code to compile: master" |
| 36 | GIT checkout master |
| 37 | fi |
| 38 | |
| 39 | } |
| garciadeblas | e460692 | 2017-01-04 14:28:04 +0100 | [diff] [blame] | 40 | |