diff --git a/hack/copy-frontend-src-to-ossmc.sh b/hack/copy-frontend-src-to-ossmc.sh index a98f9dac..ab99b2b6 100755 --- a/hack/copy-frontend-src-to-ossmc.sh +++ b/hack/copy-frontend-src-to-ossmc.sh @@ -34,6 +34,7 @@ SOURCE_REPO_URL="${DEFAULT_SOURCE_REPO_URL}" # The git ref (branch or tag name) to checkout when cloning the source repo DEFAULT_SOURCE_REF="master" SOURCE_REF="${DEFAULT_SOURCE_REF}" +PULL_REQUEST="" # This is to be the top-level directory of the local OSSM git repo. # This is where DEST_DIR should be located. @@ -44,6 +45,7 @@ while [[ $# -gt 0 ]]; do key="$1" case $key in -dr|--dest-repo) DEST_REPO="$2" ;shift;shift ;; + -pr|--pull-request) PULL_REQUEST="$2" ;shift;shift ;; -sr|--source-ref) SOURCE_REF="$2" ;shift;shift ;; -su|--source-url) SOURCE_REPO_URL="$2" ;shift;shift ;; -h|--help) @@ -58,6 +60,13 @@ Valid options: repo's "${DEST_DIR}" directory. Default: ${DEFAULT_DEST_REPO} + -pr|--pull-request + A git reference (pull request number) found in the remote source repo. This is the + Kiali pull request that will be checked out when cloning the remote source repo. + This option takes precedence over the --source-ref option + See also: --source-ref + Default: "" + -sr|--source-ref A git reference (branch or tag name) found in the remote source repo. This is the branch or tag that will be checked out when cloning the remote source repo. @@ -111,7 +120,19 @@ if [ ! -d "${ABS_SOURCE_DIR}" ]; then exit 1 fi -COMMIT_HASH="$(cd ${ABS_SOURCE_DIR} && git rev-parse HEAD)" +cd ${ABS_SOURCE_DIR} + +if [ -n "${PULL_REQUEST}" ]; then + echo "Applying changes from PR ${PULL_REQUEST} (https://github.com/kiali/kiali/pull/${PULL_REQUEST})" + git fetch origin pull/${PULL_REQUEST}/head:pr-${PULL_REQUEST} + git checkout pr-${PULL_REQUEST} + + GIT_REF="PR ${PULL_REQUEST}" +else + GIT_REF="${SOURCE_REF}" +fi + +COMMIT_HASH="$(git rev-parse HEAD)" GITHUB_COMMIT_URL="https://github.com/kiali/kiali/tree/${COMMIT_HASH}/${SOURCE_DIR}" if ! curl --silent --show-error --fail "${GITHUB_COMMIT_URL}" > /dev/null; then @@ -128,7 +149,7 @@ DEST_BRANCH="kiali-frontend-update-${DATETIME_NOW}" COMMIT_MESSAGE=$(cat <} ${DEST_BRANCH}" -fi +fi \ No newline at end of file