Yicong-Huang opened a new pull request, #60587:
URL: https://github.com/apache/spark/pull/60587
### What changes were proposed in this pull request?
When `GIT_BRANCH` is not set, `get_release_info` in
`dev/create-release/release-util.sh` derives the default release branch from
`git ls-remote --heads`. It excludes only `master` and `branch-4.x`, picks the
first remaining ref in reverse lexical order, and takes its third `/`-separated
component:
```bash
git ls-remote --heads "$ASF_REPO" |
grep -Ev 'refs/heads/(master|branch-4\.x)' |
awk '{print $2}' | sort -r | head -n 1 | cut -d/ -f3
```
This PR only considers release branches named exactly
`branch-<major>.<minor>` and picks the highest one by sorting the major and
minor versions numerically:
```bash
git ls-remote --heads "$ASF_REPO" 'refs/heads/branch-*' |
awk '{print $2}' |
sed -n 's#^refs/heads/branch-\([0-9][0-9]*\.[0-9][0-9]*\)$#\1#p' |
sort -t . -k 1,1n -k 2,2n | tail -n 1 | sed 's/^/branch-/'
```
It uses POSIX `sort` keys rather than GNU `sort -V`, because
`get_release_info` also runs on the release manager's host
(`do-release-docker.sh` calls it before starting the container), which may not
have GNU coreutils.
### Why are the changes needed?
apache/spark now has `dependabot/...` branches (e.g.
`dependabot/maven/com.google.guava-guava-33.7.1-jre`). They sort before
`branch-*` in reverse lexical order, so the default branch the release manager
is prompted with becomes `dependabot` instead of the latest release branch:
```
$ git ls-remote --heads https://github.com/apache/spark.git | grep -Ev
'refs/heads/(master|branch-4\.x)' \
| awk '{print $2}' | sort -r | head -n 1 | cut -d/ -f3
dependabot
```
The lexical sort would also pick `branch-4.9` over `branch-4.10`, and
`branch-9.9` over `branch-10.0`.
This affects the manual release entry points,
`dev/create-release/do-release-docker.sh` and
`dev/create-release/do-release.sh`, when `GIT_BRANCH` is not given. The GitHub
Actions release workflow (`.github/workflows/release.yml`) always sets
`GIT_BRANCH`, so it is not affected.
This should also be backported to `branch-4.x` (and `branch-4.4` once cut):
`branch-4.x` still has the old reverse-lexical detection. The code there
differs slightly (it excludes only `master`), so the cherry-pick may need a
small manual resolution or a separate backport PR.
### Does this PR introduce _any_ user-facing change?
No. It only changes the default branch suggested by the release scripts.
### How was this patch tested?
1. A stub-based shell test that sources `release-util.sh` and runs the real
`get_release_info`, with `git ls-remote`, `curl` and `read_config` stubbed,
feeding fake branch listings:
| Branches in the fake `ls-remote` listing | After | Before |
|---|---|---|
| master, branch-4.x, branch-4.3, branch-4.4, branch-4.9, branch-4.10,
branch-3.5, dependabot/maven/..., dependabot/bundler/... | `branch-4.10` |
`dependabot` |
| master, branch-4.x, branch-4.3, branch-4.4, branch-3.5,
dependabot/maven/..., dependabot/bundler/... | `branch-4.4` | `dependabot` |
| branch-9.9, branch-10.0, branch-10.x, branch-4.4 | `branch-10.0` |
`branch-9.9` |
| branch-4.4, branch-4.5-preview, branch-4.5.x, branch-4.5/foo,
zbranch-9.9, feature/branch-9.9 | `branch-4.4` | `zbranch-9.9` |
| master, branch-4.x, dependabot/maven/foo | (empty, so the prompt
requires input) | `dependabot` |
2. Ran `get_release_info` against https://github.com/apache/spark with only
`read_config` stubbed. The default branch is `branch-4.3` (version `4.3.1`, tag
`v4.3.1-rc1`); the old code yields `dependabot`.
3. `bash -n` and `shellcheck` 0.11.0: no new warnings (the same 16
pre-existing warnings before and after, none on the changed lines).
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]