Move lcm certificate to lcm folder in OSM helm chart
[osm/devops.git] / common / git_functions
1 #!/bin/bash
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 #
15
16
17 GIT() {
18     CMD git "$@"
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
28         GIT fetch --all --tags
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
35         for remote in `git branch -r |grep -v /HEAD`; do GIT branch --track ${remote#origin/} $remote; done
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 }
53