From 0a62fdfaf020e5630a5d1963c8cb416d5cf8f833 Mon Sep 17 00:00:00 2001 From: Federico Date: Tue, 16 Jun 2026 17:40:47 +0800 Subject: [PATCH] `unreleased-commits` - Show when creating a release --- source/features/action-pr-link.tsx | 2 ++ source/features/unreleased-commits.tsx | 40 ++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/source/features/action-pr-link.tsx b/source/features/action-pr-link.tsx index e0e8982586e6..7dada0189f11 100644 --- a/source/features/action-pr-link.tsx +++ b/source/features/action-pr-link.tsx @@ -60,4 +60,6 @@ https://github.com/refined-github/refined-github/pull/6794 https://github.com/refined-github/refined-github/pull/6794/commits +https://github.com/refined-github/refined-github/actions/runs/19100812913/usage + */ diff --git a/source/features/unreleased-commits.tsx b/source/features/unreleased-commits.tsx index 3b06099f348e..4e12db8685b8 100644 --- a/source/features/unreleased-commits.tsx +++ b/source/features/unreleased-commits.tsx @@ -165,14 +165,40 @@ async function addToReleases(releasesFilter: HTMLInputElement): Promise { widget.classList.add('mr-md-0', 'mr-2'); } -async function initHome(signal: AbortSignal): Promise { +async function addToNewRelease(header: HTMLElement): Promise { + const {latestTag, aheadBy} = await repoPublishState.get(); + const isAhead = aheadBy > 0; + + if (!latestTag || !isAhead) { + return; + } + + const defaultBranch = await getDefaultBranch(); + + header.append( + ' ', + + {pluralize(aheadBy, '$$ unreleased commit')} + , + ` on ${defaultBranch} since `, + + {abbreviateString(latestTag, 30)} + , + ); +} + +function initHome(signal: AbortSignal): void { observe(branchSelector, addToHome, {signal}); } -async function initReleases(signal: AbortSignal): Promise { +function initReleases(signal: AbortSignal): void { observe('input#release-filter', addToReleases, {signal}); } +function initNewRelease(signal: AbortSignal): void { + observe('.js-tag-status-message[data-state="empty"]', addToNewRelease, {signal}); +} + void features.add(import.meta.url, { asLongAs: [ isDefaultBranch, @@ -189,6 +215,13 @@ void features.add(import.meta.url, { ], requiresToken: true, init: initReleases, +}, { + include: [ + // Detections run on all pages, even not repos + () => getRepo()?.path === 'releases/new', + ], + requiresToken: true, + init: initNewRelease, }); /* @@ -213,4 +246,7 @@ https://github.com/refined-github/refined-github/releases Releases page with changelog file https://github.com/fczbkk/css-selector-generator/releases +Realeasing a new version +https://github.com/refined-github/refined-github/releases/new + */