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