github.com/shashidharatd/test-infra@v0.0.0-20171006011030-71304e1ca560/mungegithub/publisher/util/fetch-all-latest-and-push.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2017 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -o errexit
    18  set -o nounset
    19  set -o pipefail
    20  
    21  if [ ! $# -eq 2 ]; then
    22      echo "usage: $0 github_user_name kube_root"
    23      exit 1
    24  fi
    25  
    26  USER="${1}"
    27  KUBE_ROOT="${2}"
    28  
    29  REPOS="apimachinery,api,client-go,apiserver,kube-aggregator,sample-apiserver,apiextensions-apiserver"
    30  
    31  IFS=',' read -a repos <<< "${REPOS}"
    32  repo_count=${#repos[@]}
    33  
    34  echo "=================="
    35  echo "safety check"
    36  echo "=================="
    37  # safety check
    38  for (( i=0; i<${repo_count}; i++ )); do
    39      cd $KUBE_ROOT/../"${repos[i]}"
    40      if [[ $(git config --get remote.origin.url) != *"${USER}"* ]]; then
    41          echo "origin is not right, expect to contain ${USER}, got $(git config --get remote.origin.url)"
    42          exit 1
    43      fi
    44  done
    45  
    46  echo "=================="
    47  echo " sync masters"
    48  echo "=================="
    49  for (( i=0; i<${repo_count}; i++ )); do
    50      cd $KUBE_ROOT/../"${repos[i]}"
    51      echo "repo=${repos[i]}"
    52      git fetch upstream
    53      git checkout master
    54      git reset --hard upstream/master
    55      git push -f origin master
    56  done
    57  
    58  echo "=================="
    59  echo "sync release-1.6"
    60  echo "=================="
    61  
    62  REPOS="apimachinery,apiserver,kube-aggregator,sample-apiserver"
    63  IFS=',' read -a repos <<< "${REPOS}"
    64  repo_count=${#repos[@]}
    65  for (( i=0; i<${repo_count}; i++ )); do
    66      cd $KUBE_ROOT/../"${repos[i]}"
    67      echo "repo=${repos[i]}"
    68      git branch -f release-1.6 upstream/release-1.6
    69      git push -f origin release-1.6
    70  done
    71  
    72  echo "=================="
    73  echo "sync release-1.7"
    74  echo "=================="
    75  
    76  REPOS="apimachinery"
    77  IFS=',' read -a repos <<< "${REPOS}"
    78  repo_count=${#repos[@]}
    79  for (( i=0; i<${repo_count}; i++ )); do
    80      cd $KUBE_ROOT/../"${repos[i]}"
    81      echo "repo=${repos[i]}"
    82      git branch -f release-1.7 upstream/release-1.7
    83      git push -f origin release-1.7
    84  done
    85  
    86  # client-go follows semver, so its versions are different from kubernetes.
    87  echo "=================="
    88  echo "sync client-go release-2.0,release-3.0 and release-4.0"
    89  echo "=================="
    90  
    91  BRANCHES="release-2.0,release-3.0,release-4.0"
    92  IFS=',' read -a branches <<< "${BRANCHES}"
    93  branch_count=${#branches[@]}
    94  for (( i=0; i<${branch_count}; i++ )); do
    95      cd "$KUBE_ROOT/../client-go"
    96      echo "repo=client-go"
    97      git branch -f "${branches[i]}" upstream/"${branches[i]}" 
    98      git push -f origin "${branches[i]}"
    99  done