|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright 2019 The Kubernetes Authors. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -o errexit |
| 17 | +set -o nounset |
| 18 | +set -o pipefail |
| 19 | + |
| 20 | +bold_blue() { |
| 21 | + echo -e "\x1B[1;34m${*}\x1B[0m" |
| 22 | +} |
| 23 | + |
| 24 | +bold_yellow() { |
| 25 | + echo -e "\x1B[1;33m${*}\x1B[0m" |
| 26 | +} |
| 27 | + |
| 28 | +main() { |
| 29 | + bold_blue "Checking out latest upstream ..." |
| 30 | + git fetch https://github.com/kubernetes/test-infra master |
| 31 | + git checkout FETCH_HEAD |
| 32 | + |
| 33 | + bold_blue "Finding most recent bump commit ..." |
| 34 | + local most_recent_bump |
| 35 | + local most_recent_bump_commmit |
| 36 | + most_recent_bump="$(git log --no-merges --extended-regexp \ |
| 37 | + --grep='Update prow to v[a-f0-9]+-[a-f0-9]+, and other images as necessary\.' \ |
| 38 | + --pretty=oneline -n 1)" |
| 39 | + bold_yellow "Matching Commit: ${most_recent_bump}" |
| 40 | + most_recent_bump_commmit=$(cut -f1 -d ' ' <<< "${most_recent_bump}") |
| 41 | + echo "Commit SHA: ${most_recent_bump_commmit}" |
| 42 | + |
| 43 | + bold_blue "Creating revert ..." |
| 44 | + local revert_branch |
| 45 | + revert_branch="revert-$(date +'%s')-${most_recent_bump_commmit}" |
| 46 | + git checkout -b "${revert_branch}" |
| 47 | + git revert --no-edit "${most_recent_bump_commmit}" |
| 48 | + |
| 49 | + bold_blue "Pushing branch ..." |
| 50 | + git -c push.default=current push |
| 51 | + |
| 52 | + bold_yellow "You should now file a pull request from your ${revert_branch} branch." |
| 53 | +} |
| 54 | + |
| 55 | +main "$@" |
0 commit comments