Repository navigation
fix(package-rules): make fetchChangeLogs work at update level #42368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
9de2c9d
7de25aa
979cd77
c56d1a5
afdbf0e
9873069
6dae3d3
e1e5d5e
cc85322
c2bf286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||||
| import type { FetchChangeLogsOptions } from '../../../config/types.ts'; | ||||||
| import * as p from '../../../util/promises.ts'; | ||||||
| import type { BranchUpgradeConfig } from '../../types.ts'; | ||||||
| import { getChangeLogJSON } from '../update/pr/changelog/index.ts'; | ||||||
| import type { EmbedChangelogsOptions } from './types.ts'; | ||||||
|
|
||||||
| export async function embedChangelog( | ||||||
| upgrade: BranchUpgradeConfig, | ||||||
|
|
@@ -43,8 +45,30 @@ export async function embedChangelog( | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| export async function embedChangelogs( | ||||||
| branches: BranchUpgradeConfig[], | ||||||
| ): Promise<void> { | ||||||
| await p.map(branches, embedChangelog, { concurrency: 10 }); | ||||||
| // Merges the top-level fetchChangeLogs value with the upgrade's fetchChangeLogs value (prioritizing the latter, if defined). | ||||||
| function resolveFetchChangeLogs( | ||||||
| fetchChangeLogs?: FetchChangeLogsOptions, | ||||||
| upgradeFetchChangeLogs?: FetchChangeLogsOptions, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this is always set on upgrades object 🤔 please create another reproduction:
|
||||||
| ): FetchChangeLogsOptions { | ||||||
| // Default to 'pr' if top-level fetchChangeLogs is undefined. | ||||||
| let fetchChangeLogsResolved: FetchChangeLogsOptions = fetchChangeLogs ?? 'pr'; | ||||||
| if (upgradeFetchChangeLogs) { | ||||||
| // Override using the upgrade's fetchChangeLogs value. | ||||||
| fetchChangeLogsResolved = upgradeFetchChangeLogs; | ||||||
| } | ||||||
| return fetchChangeLogsResolved; | ||||||
| } | ||||||
|
|
||||||
| export async function embedChangelogs({ | ||||||
| branches, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| stage, | ||||||
| fetchChangeLogs, | ||||||
| }: EmbedChangelogsOptions): Promise<void> { | ||||||
| // Filter down to branch upgrades that match the stage and fetchChangeLogs configuration. | ||||||
| const upgrades = branches.filter( | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| (upgrade) => | ||||||
| resolveFetchChangeLogs(fetchChangeLogs, upgrade.fetchChangeLogs) === | ||||||
| stage, | ||||||
| ); | ||||||
| await p.map(upgrades, embedChangelog, { concurrency: 10 }); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| import type { FetchChangeLogsOptions } from '../../../config/types.ts'; | ||||||
| import type { BranchUpgradeConfig } from '../../types.ts'; | ||||||
|
|
||||||
| // Extend is ensures that U is a subset of T, helping us be sure that we get a typescript error should | ||||||
| // FetchChangeLogOptions someday remove 'branch' or 'pr' from the union. | ||||||
| type Extends<T, U extends T> = U; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to |
||||||
| export type SupportedChangelogStages = Extends< | ||||||
| FetchChangeLogsOptions, | ||||||
| 'branch' | 'pr' | ||||||
| >; | ||||||
|
|
||||||
| export interface EmbedChangelogsOptions { | ||||||
| branches: BranchUpgradeConfig[]; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong name
Suggested change
|
||||||
| stage: SupportedChangelogStages; | ||||||
| fetchChangeLogs?: FetchChangeLogsOptions; | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global option should still be first. @jamietanna WDYT?