From e1b6905774522afbb1f895c5ded906a877a74bbf Mon Sep 17 00:00:00 2001 From: collissimo <148455189+collissimo@users.noreply.github.com> Date: Fri, 23 Oct 2026 19:10:54 +0200 Subject: [PATCH] Fork release: fork changes between the built commits, not the tags A release tag lands on the branch head at publish time, so a pull request merged during a build was credited to that build. Co-Authored-By: Claude Opus 5.5 --- FORK.md | 2 +- fork/release-notes.sh | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/FORK.md b/FORK.md index 0447a3df6832d..ed213b325ab06 100644 --- a/FORK.md +++ b/FORK.md @@ -84,7 +84,7 @@ check. `T3CODE_CLERK_CLI_OAUTH_CLIENT_ID`. Upstream's telemetry tokens are deliberately not copied. - The tag sits on the `collin/main` commit. The release notes (`fork/release-notes.sh`) are upstream's notes for every nightly since the previous fork build, then the fork's pull - requests since then; the update popup shows them. A hidden comment at the end records the fork + requests and direct commits since the commit that build built; the update popup shows them. A hidden comment at the end records the fork and upstream commits, which the skip check, the watcher and the watchdog read. ## Keeping changes mergeable diff --git a/fork/release-notes.sh b/fork/release-notes.sh index f4b1a61778d62..9ccf4d4a4aae0 100755 --- a/fork/release-notes.sh +++ b/fork/release-notes.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash # Release notes of a fork build: the notes of every upstream nightly since the previous fork -# release, then the fork's own pull requests since then. The app's update popup and the GitHub -# release page both show this body. A trailing HTML comment, invisible in both, records what was -# built for fork-release.yml and the watcher. +# release, then the fork's own changes since the commit that release built. The app's update +# popup and the GitHub release page both show this body. A trailing HTML comment, invisible in +# both, records what was built for fork-release.yml and the watcher. # -# Env: REPO (owner/name), TAG (new release tag), TARGET (fork commit), UPSTREAM_TAG, -# UPSTREAM_SHA, PREVIOUS_TAG (the fork's latest release before this one, may be empty). +# Env: REPO (owner/name), TARGET (fork commit), UPSTREAM_TAG, UPSTREAM_SHA, PREVIOUS_TAG (the +# fork's latest release before this one, may be empty). set -euo pipefail # Only the bullet list of a GitHub "What's Changed" body; the app stops reading at @@ -15,9 +15,11 @@ changes() { } previous_upstream="" +previous_fork="" if [[ -n "$PREVIOUS_TAG" ]]; then previous_body=$(gh release view "$PREVIOUS_TAG" --repo "$REPO" --json body --jq .body) previous_upstream=$(grep -oE 'upstream-tag=[^ ]+|builds of upstream [^ ]+' <<<"$previous_body" | head -n 1 | sed -E 's/.*[= ]//' || true) + previous_fork=$(grep -oE 'fork=[0-9a-f]+|Fork: [0-9a-f]+' <<<"$previous_body" | head -n 1 | sed -E 's/.*[= ]//' || true) fi # Upstream nightlies after the previous build's, up to this build's, oldest first: the app @@ -33,16 +35,30 @@ for nightly in $nightlies; do upstream_changes+=$'\n' done +# Between the built commits, not the release tags: a tag lands on the branch head at publish +# time, which can already hold changes the build did not. First-parent commits of collin/main +# are its pull request merges, direct commits and upstream syncs; the syncs are left out. fork_changes="" -if [[ -n "$PREVIOUS_TAG" ]]; then - fork_changes=$(gh api "repos/$REPO/releases/generate-notes" -f tag_name="$TAG" \ - -f target_commitish="$TARGET" -f previous_tag_name="$PREVIOUS_TAG" --jq .body | changes) +if [[ -n "$previous_fork" ]]; then + git_dir=$(mktemp -d) + git -C "$git_dir" init -q + git -C "$git_dir" fetch -q --filter=tree:0 --no-tags "https://github.com/$REPO.git" "$TARGET" "$previous_fork" + while read -r commit; do + subject=$(git -C "$git_dir" log -1 --format=%s "$commit") + if [[ "$subject" =~ ^Merge\ pull\ request\ \#([0-9]+) ]]; then + title=$(git -C "$git_dir" log -1 --format=%b "$commit" | head -n 1) + fork_changes+="* ${title:-$subject} in https://github.com/$REPO/pull/${BASH_REMATCH[1]}"$'\n' + elif [[ $(git -C "$git_dir" rev-list --parents -n 1 "$commit" | wc -w) -eq 2 ]]; then + fork_changes+="* $subject"$'\n' + fi + done < <(git -C "$git_dir" rev-list --first-parent --reverse "$previous_fork..$TARGET") + rm -rf "$git_dir" fi if [[ -n "${upstream_changes//[[:space:]]/}" ]]; then printf '## T3 Code\n%s\n' "$upstream_changes" fi if [[ -n "$fork_changes" ]]; then - printf '## Fork\n%s\n\n' "$fork_changes" + printf '## Fork\n%s\n' "$fork_changes" fi printf '\n' "$TARGET" "$UPSTREAM_SHA" "$UPSTREAM_TAG"