github.com/openshift/docker-source-to-images@v1.2.0/hack/rebase-to-origin.sh (about)

     1  #!/bin/bash
     2  #
     3  # This script will create a rebase commit in the OpenShift Origin Git repository
     4  # based on the current HEAD.
     5  #
     6  # NOTE: Make sure all your changes are committed and there are no junk files
     7  #       present in the pkg/ folder.
     8  #
     9  
    10  set -o errexit
    11  set -o nounset
    12  set -o pipefail
    13  
    14  readonly S2I_ROOT=$(
    15    root=$(dirname "${BASH_SOURCE}")/..
    16    unset CDPATH
    17    cd "${root}"
    18    pwd
    19  )
    20  #readonly OS_ROOT="${S2I_ROOT/%\/source-to-image/\/ose}"
    21  readonly OS_ROOT="${S2I_ROOT/%\/source-to-image/\/origin}"
    22  
    23  source "${S2I_ROOT}/hack/util.sh"
    24  
    25  # Exclude these packages from source-to-image explicitly
    26  readonly exclude_pkgs=(
    27    pkg/cmd
    28    pkg/config
    29    pkg/create
    30    pkg/docker/test
    31    pkg/run
    32    pkg/version
    33    pkg/test
    34  )
    35  
    36  readonly origin_s2i_vendor_dir="${OS_ROOT}/vendor/github.com/openshift/source-to-image"
    37  readonly s2i_ref="$(git -C ${S2I_ROOT} rev-parse --verify HEAD)"
    38  readonly s2i_short_ref="$(git -C ${S2I_ROOT} rev-parse --short HEAD)"
    39  readonly s2i_describe_tags="$(git -C ${S2I_ROOT} describe --tags HEAD)"
    40  readonly s2i_godeps_ref="$(grep -m1 -A2 'openshift/source-to-image' ${OS_ROOT}/Godeps/Godeps.json |
    41    grep Rev | cut -d ':' -f2 | sed -e 's/"//g' -e 's/^[[:space:]]*//')"
    42  readonly s2i_godeps_comment="$(grep -m1 -A2 'openshift/source-to-image' ${OS_ROOT}/Godeps/Godeps.json |
    43    grep Comment | cut -d ':' -f2 | sed -e 's/[",]//g' -e 's/^[[:space:]]*//')"
    44  
    45  pushd "${OS_ROOT}" >/dev/null
    46    git checkout -B "s2i-${s2i_short_ref}-bump" master
    47    rm -rf "${origin_s2i_vendor_dir}"/*
    48    cp -R "${S2I_ROOT}/pkg" "${origin_s2i_vendor_dir}/."
    49    cp "${S2I_ROOT}/LICENSE" "${origin_s2i_vendor_dir}/."
    50    # remove test files from the vendor folder.
    51    find ${origin_s2i_vendor_dir}/pkg -name "*_test.go" -delete
    52    # Remove all explicitly excluded packages
    53    for pkg in "${exclude_pkgs[@]}"; do
    54      rm -rvf "${origin_s2i_vendor_dir}/${pkg}"
    55    done
    56  
    57    # Bump the origin Godeps.json file
    58    s2i::util::sed "s/${s2i_godeps_ref}/${s2i_ref}/g" "${OS_ROOT}/Godeps/Godeps.json"
    59    s2i::util::sed "s/${s2i_godeps_comment}/${s2i_describe_tags}/g" "${OS_ROOT}/Godeps/Godeps.json"
    60  
    61    # Make a commit with proper message
    62    git add Godeps vendor && git commit -m "bump(github.com/openshift/source-to-image): ${s2i_ref}"
    63  popd