Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 25 additions & 9 deletions fork/release-notes.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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 '<!-- fork-release fork=%s upstream=%s upstream-tag=%s -->\n' "$TARGET" "$UPSTREAM_SHA" "$UPSTREAM_TAG"
Loading