Skip to content

Commit

Permalink
refactor(release-notes): extract shouldSkipChangelogMd (#23274)
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy authored Jul 24, 2023
1 parent 1b93263 commit 3c29bd4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
25 changes: 25 additions & 0 deletions lib/workers/repository/update/pr/changelog/release-notes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getReleaseNotes,
getReleaseNotesMd,
releaseNotesCacheMinutes,
shouldSkipChangelogMd,
} from './release-notes';
import type {
ChangeLogNotes,
Expand Down Expand Up @@ -1340,6 +1341,20 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
});
});

it('handles skipped packages', async () => {
const res = await getReleaseNotesMd(
{
...githubProject,
repository: 'facebook/react-native',
},
partial<ChangeLogRelease>({
version: '0.72.3',
gitRef: '0.72.3',
})
);
expect(res).toBeNull();
});

it('isUrl', () => {
expect(versionOneNotes).not.toMatchObject(versionTwoNotes);
});
Expand All @@ -1348,5 +1363,15 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
expect(versionOneNotes).not.toMatchObject(versionTwoNotes);
});
});

describe('shouldSkipChangelogMd', () => {
it('should skip for flagged repository', () => {
expect(shouldSkipChangelogMd('facebook/react-native')).toBeTrue();
});

it('should continue for other repository', () => {
expect(shouldSkipChangelogMd('some/repo')).toBeFalse();
});
});
});
});
16 changes: 13 additions & 3 deletions lib/workers/repository/update/pr/changelog/release-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import type {
const markdown = new MarkdownIt('zero');
markdown.enable(['heading', 'lheading']);

const repositoriesToSkipMdFetching = ['facebook/react-native'];

export async function getReleaseList(
project: ChangeLogProject,
release: ChangeLogRelease
Expand Down Expand Up @@ -302,11 +304,11 @@ export async function getReleaseNotesMd(
const { baseUrl, repository } = project;
const version = release.version;
logger.trace(`getReleaseNotesMd(${repository}, ${version})`);
const skippedRepos = ['facebook/react-native'];
// istanbul ignore if
if (skippedRepos.includes(repository)) {

if (shouldSkipChangelogMd(repository)) {
return null;
}

const changelog = await getReleaseNotesMdFile(project);
if (!changelog) {
return null;
Expand Down Expand Up @@ -445,3 +447,11 @@ export async function addReleaseNotes(
}
return output;
}

/**
* Skip fetching changelog/release-notes markdown files.
* Will force a fallback to using GitHub release notes
*/
export function shouldSkipChangelogMd(repository: string): boolean {
return repositoriesToSkipMdFetching.includes(repository);
}

0 comments on commit 3c29bd4

Please sign in to comment.