1 ##############################################################################
2 # Copyright (c) 2016 Dan Radez (Red Hat) and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 # ARG 1: opnfv-tht or opnfv-puppet-tripleo
14 # Use apex tripleo-heat-templates fork
17 local ref="stable/euphrates"
18 local repo="https://github.com/trozet/$1"
20 if git log -1 | grep "${1}-pr:" | grep -o '[0-9]*'; then
21 pr_num=$(git log -1 | grep "${1}-pr:" | grep -o '[0-9]*')
24 if [ "$pr_num" != "" ]; then
25 echo "Using pull request $pr_num from $repo"
26 # Source credentials since we are rate limited to 60/day
27 if [ -f ~/.githubcreds ]; then
29 ghcreds=" -u $GHUSERNAME:$GHACCESSTOKEN"
32 PR=$(curl $ghcreds https://api.github.com/repos/trozet/$1/pulls/$pr_num)
34 # Do not pull from merged branches
35 MERGED=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['merged']")
36 if [ "$MERGED" == "False" ]; then
37 ref=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['ref']")
38 echo "Setting GitHub Ref to: $REF"
39 repo=$(python -c "import json; print json.loads('''$PR'''.replace('\n', '').replace('\r', ''))['head']['repo']['clone_url']")
40 echo "Setting GitHub URL to: $repo"
45 git clone $repo -b $ref $1