Re: [PATCH v6 1/2] scripts: generate_rust_analyzer.py: add versioning infrastructure
From: Jesung Yang
Date: Thu May 07 2026 - 08:58:44 EST
On Tue, May 5, 2026 at 7:01 AM Tamir Duberstein <tamird@xxxxxxxxxx> wrote:
> On Mon, 04 May 2026 22:20:59 +0900, Jesung Yang <y.j3ms.n@xxxxxxxxx> wrote:
> > diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> > index d5f9a0ca742c..934698c7eb95 100755
> > --- a/scripts/generate_rust_analyzer.py
> > +++ b/scripts/generate_rust_analyzer.py
> > @@ -343,6 +346,153 @@ def generate_crates(
> > [ ... skip 46 lines ... ]
> > + # git -C ./rust-analyzer describe --tags --abbrev=0 "$hash"
> > + # )
> > + #
> > + # link_prefix="https://github.com/rust-lang/rust-analyzer/releases/tag"
> > + # echo "$link_prefix/$tag_predates"
> > + # ```
>
> I think we talked about this being a bit more defensive with (at least)
> set -eu. How's this?
>
> #!/usr/bin/env bash
>
> set -euo pipefail
>
> RUST_VERSION=$1
>
> grep_args=()
> while IFS= read -r subject; do
> grep_args+=(--grep "$subject")
> done < <(git -C rust log \
> --fixed-strings \
> --format='%s' \
> --grep 'Merge pull request #' \
> --merges \
> --no-follow \
> -n 10 \
> "$RUST_VERSION" \
> -- src/tools/rust-analyzer
> )
>
> tag_predates=$(
> git -C rust-analyzer log \
> --fixed-strings \
> --format='%(describe:tags,abbrev=0)' \
> --merges \
> -n 1 \
> "${grep_args[@]}"
> )
>
> link_prefix="https://github.com/rust-lang/rust-analyzer/releases/tag"
> echo "$link_prefix/$tag_predates"
>
> Note I added `--merges` in the first `git log`, inlined `LOOKAHEAD` (and
> reduced it to 10, now that it's only merge commits), and replaced piping
> into grep with `--grep`. The second and third `git log` commands are
> combined.
I don't see the `--no-follow` option in the man page, so I'd go for
`-c log.follow=false`. Should we also use that for the second `git log`?
Otherwise, merge commits might be lost, right?
> > [ ... skip 60 lines ... ]
> > + return ra_version_output
> > + except FileNotFoundError:
> > + return None
> > +
> > +def map_ra_version_baseline(ra_version_output: str) -> RaVersionInfo:
> > + baselines = reversed(RaVersionInfo)
>
> This is an iterator but it's possible for both `version_match` and
> `date_match` to use it, which means the latter will observe an empty
> iterator.
Nice catch, I'll wrap it in `list()`.
Best regards,
Jesung