|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
| 3 | +# Copyright 2025 the libevm authors. |
| 4 | +# |
| 5 | +# The libevm additions to go-ethereum are free software: you can redistribute |
| 6 | +# them and/or modify them under the terms of the GNU Lesser General Public License |
| 7 | +# as published by the Free Software Foundation, either version 3 of the License, |
| 8 | +# or (at your option) any later version. |
| 9 | +# |
| 10 | +# The libevm additions are distributed in the hope that they will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
| 13 | +# General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Lesser General Public License |
| 16 | +# along with the go-ethereum library. If not, see |
| 17 | +# <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +# Usage: run `./cherrypick.sh` on a branch intended to become a release. |
| 20 | +# |
| 21 | +# Reads the contents of ./cherrypicks, filters out commits that are already |
| 22 | +# ancestors of HEAD, and calls `git cherry-pick` with the remaining commit |
| 23 | +# hashes. |
| 24 | + |
3 | 25 | set -eu; |
4 | 26 | set -o pipefail; |
5 | 27 |
|
6 | 28 | SELF_DIR=$(dirname $0) |
7 | 29 | # The format of the `cherrypicks` file is guaranteed by a test so we can use simple parsing here. |
8 | 30 | CHERRY_PICKS=$(cat "${SELF_DIR}/cherrypicks" | grep -Pv "^#" | awk '{print $1}') |
9 | | -RELEASE_REF="main"; |
10 | 31 |
|
11 | 32 | commits=() |
12 | 33 | for commit in ${CHERRY_PICKS}; do |
13 | | - git merge-base --is-ancestor "${commit}" "${RELEASE_REF}" && \ |
| 34 | + git merge-base --is-ancestor "${commit}" HEAD && \ |
14 | 35 | echo "Skipping ${commit} already in history" && \ |
15 | 36 | continue; |
16 | 37 |
|
17 | 38 | echo "Cherry-picking ${commit}"; |
18 | 39 | commits+=("${commit}"); |
19 | 40 | done |
20 | 41 |
|
| 42 | +if [[ -z "${commits[@]// }" ]]; then # $x// removes whitespace |
| 43 | + echo "No commits to cherry-pick"; |
| 44 | + exit 0; |
| 45 | +fi |
| 46 | + |
21 | 47 | git cherry-pick "${commits[@]}"; |
0 commit comments