How to use normalizeCommits method in Best

Best JavaScript code snippet using best

changelog.test.ts

Source:changelog.test.ts Github

copy

Full Screen

...91});92describe('Hooks', () => {93 test('title', async () => {94 const changelog = new Changelog(dummyLog(), testOptions());95 const normalized = await logParse.normalizeCommits([96 makeCommitFromMsg('Some Feature (#1234)')97 ]);98 changelog.hooks.renderChangelogTitle.tap(99 'test',100 (label, changelogTitles) => `:heart: ${changelogTitles[label]} :heart:`101 );102 changelog.loadDefaultHooks();103 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();104 });105 test('author', async () => {106 const changelog = new Changelog(dummyLog(), testOptions());107 const normalized = await logParse.normalizeCommits([108 makeCommitFromMsg('Some Feature (#1234)')109 ]);110 changelog.hooks.renderChangelogAuthor.tap(111 'test',112 (author, commit) => `:heart: ${author.name}/${commit.authorEmail} :heart:`113 );114 changelog.hooks.renderChangelogAuthorLine.tap(115 'test',116 (author, user) => `:shipit: ${author.name} (${user})`117 );118 changelog.loadDefaultHooks();119 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();120 });121});122describe('generateReleaseNotes', () => {123 test('should create note for PR commits', async () => {124 const changelog = new Changelog(dummyLog(), testOptions());125 changelog.loadDefaultHooks();126 const normalized = await logParse.normalizeCommits([127 makeCommitFromMsg('Some Feature (#1234)', { labels: ['minor'] })128 ]);129 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();130 });131 test('should omit authors with invalid email addresses', async () => {132 const changelog = new Changelog(dummyLog(), testOptions());133 changelog.loadDefaultHooks();134 const normalized = await logParse.normalizeCommits([135 makeCommitFromMsg('Some Feature (#1234)', { labels: ['minor'] })136 ]);137 normalized[0].authors[0].username = 'invalid-email-address';138 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();139 });140 test('should create note for PR commits without labels', async () => {141 const changelog = new Changelog(dummyLog(), testOptions());142 changelog.loadDefaultHooks();143 const normalized = await logParse.normalizeCommits([144 makeCommitFromMsg('Some Feature (#1234)')145 ]);146 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();147 });148 test('should create note for PR commits without labels with custom patch label', async () => {149 const options = testOptions();150 options.labels = [151 {152 name: 'Version: Patch',153 changelogTitle: '🐛 Bug Fix',154 description: 'N/A',155 releaseType: SEMVER.patch156 }157 ];158 const changelog = new Changelog(dummyLog(), options);159 changelog.loadDefaultHooks();160 const normalized = await logParse.normalizeCommits([161 makeCommitFromMsg('Some Feature (#1234)')162 ]);163 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();164 });165 test('should create note for PR commits with only non config labels', async () => {166 const changelog = new Changelog(dummyLog(), testOptions());167 changelog.loadDefaultHooks();168 const normalized = await logParse.normalizeCommits([169 makeCommitFromMsg('Some Feature (#1234)', {170 labels: ['someOtherNonConfigLabel']171 })172 ]);173 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();174 });175 test('should prefer section with highest releaseType for PR with multiple labels', async () => {176 const options = testOptions();177 options.labels = [178 {179 name: 'Internal',180 changelogTitle: 'Internal Section',181 releaseType: 'none'182 },183 {184 name: 'Version: Minor',185 changelogTitle: 'Minor Section',186 releaseType: SEMVER.minor187 }188 ];189 const changelog = new Changelog(dummyLog(), options);190 changelog.loadDefaultHooks();191 const normalized = await logParse.normalizeCommits([192 makeCommitFromMsg('Some Feature (#1234)', {193 labels: ['Internal', 'Version: Minor']194 })195 ]);196 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();197 });198 test('should prefer section defined first in config for PR with multiple labels of same releaseType', async () => {199 const options = testOptions();200 options.labels = [201 {202 name: 'Internal',203 changelogTitle: 'Internal Section',204 releaseType: 'none'205 },206 {207 name: 'Typescript',208 changelogTitle: 'Typescript Section',209 releaseType: 'none'210 }211 ];212 const changelog = new Changelog(dummyLog(), options);213 changelog.loadDefaultHooks();214 const normalized = await logParse.normalizeCommits([215 makeCommitFromMsg('Some Feature (#1234)', {216 labels: ['Typescript', 'Internal']217 })218 ]);219 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();220 });221 test('should prefer section of default label for PR with multiple labels of same releaseType', async () => {222 const options = testOptions();223 options.labels = [224 ...options.labels,225 {226 name: 'Minor2',227 changelogTitle: 'Minor 2 Section',228 releaseType: SEMVER.minor229 }230 ];231 const changelog = new Changelog(dummyLog(), options);232 changelog.loadDefaultHooks();233 const normalized = await logParse.normalizeCommits([234 makeCommitFromMsg('Some Feature (#1234)', { labels: ['Minor2', 'minor'] })235 ]);236 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();237 });238 test('should use username if present', async () => {239 const changelog = new Changelog(dummyLog(), testOptions());240 changelog.loadDefaultHooks();241 const normalized = await logParse.normalizeCommits([242 makeCommitFromMsg('Some Feature (#1234)', {243 labels: ['minor'],244 username: 'adam'245 })246 ]);247 normalized[0].authors[0].username = 'adam';248 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();249 });250 test('should combine pr w/no label and labelled pr', async () => {251 const changelog = new Changelog(dummyLog(), testOptions());252 changelog.loadDefaultHooks();253 const normalized = await logParse.normalizeCommits([254 makeCommitFromMsg('Some Feature (#1234)'),255 makeCommitFromMsg('Third', { labels: ['patch'] })256 ]);257 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();258 });259 test('should include prs with released label', async () => {260 const changelog = new Changelog(dummyLog(), testOptions());261 changelog.loadDefaultHooks();262 const normalized = await logParse.normalizeCommits([263 makeCommitFromMsg('Some Feature (#1234)', { labels: ['released'] }),264 makeCommitFromMsg('Third', { labels: ['patch'] })265 ]);266 expect(await changelog.generateReleaseNotes(normalized)).toMatchSnapshot();267 });268 test("should use only email if author name doesn't exist", async () => {269 const changelog = new Changelog(dummyLog(), testOptions());270 changelog.loadDefaultHooks();271 const commits = await logParse.normalizeCommits([272 {273 hash: 'foo',274 files: [],275 labels: [],276 authorEmail: 'adam@dierkens.com',277 subject: 'Another Feature (#1234)'278 },279 {280 hash: 'foo',281 files: [],282 labels: [],283 subject: 'One Feature (#1235)'284 }285 ]);286 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();287 });288 test('should include PR-less commits as patches', async () => {289 const changelog = new Changelog(dummyLog(), testOptions());290 changelog.loadDefaultHooks();291 const commits = await logParse.normalizeCommits([292 {293 hash: '1',294 files: [],295 authorName: 'Adam Dierkens',296 authorEmail: 'adam@dierkens.com',297 subject: 'I was a push to master\n\n',298 labels: ['pushToBaseBranch']299 },300 {301 hash: '2',302 files: [],303 authorName: 'Adam Dierkens',304 authorEmail: 'adam@dierkens.com',305 subject: 'First Feature (#1235)',306 labels: ['minor']307 }308 ]);309 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();310 });311 test('should order the section major, minor, patch, then the rest', async () => {312 const options = testOptions();313 options.labels = [314 options.labels.find(l => l.name === 'documentation')!,315 options.labels.find(l => l.name === 'internal')!,316 options.labels.find(l => l.name === 'patch')!,317 options.labels.find(l => l.name === 'minor')!,318 options.labels.find(l => l.name === 'major')!319 ];320 const changelog = new Changelog(dummyLog(), options);321 changelog.loadDefaultHooks();322 const commits = await logParse.normalizeCommits([323 {324 hash: '0a',325 files: [],326 authorName: 'Adam Dierkens',327 authorEmail: 'adam@dierkens.com',328 subject: 'something\n\n',329 labels: ['internal']330 },331 {332 hash: '0',333 files: [],334 authorName: 'Adam Dierkens',335 authorEmail: 'adam@dierkens.com',336 subject: 'docs\n\n',337 labels: ['documentation']338 },339 {340 hash: '1',341 files: [],342 authorName: 'Adam Dierkens',343 authorEmail: 'adam@dierkens.com',344 subject: 'I was a push to master\n\n',345 labels: ['patch']346 },347 {348 hash: '2',349 files: [],350 authorName: 'Adam Dierkens',351 authorEmail: 'adam@dierkens.com',352 subject: 'First Feature (#1235)',353 labels: ['minor']354 },355 {356 hash: '2',357 files: [],358 authorName: 'Adam Dierkens',359 authorEmail: 'adam@dierkens.com',360 subject: 'First Feature (#1235)',361 labels: ['major']362 }363 ]);364 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();365 });366 test('should match authors correctly', async () => {367 const options = testOptions();368 const changelog = new Changelog(dummyLog(), options);369 changelog.loadDefaultHooks();370 const commits = await logParse.normalizeCommits([371 {372 hash: '0a',373 files: [],374 subject: 'something\n\n',375 labels: ['internal']376 },377 {378 hash: '0',379 files: [],380 subject: 'docs\n\n',381 labels: ['documentation']382 },383 {384 hash: '0',385 files: [],386 subject: 'another\n\n',387 labels: ['documentation']388 }389 ]);390 commits.forEach((commit, index) => {391 switch (index) {392 case 0:393 commit.authors = [{ email: 'andrew@email.com' }];394 break;395 case 1:396 commit.authors = [{ email: 'kendall@email.com' }];397 break;398 case 2:399 commit.authors = [{ username: 'rdubzz' }];400 break;401 default:402 }403 });404 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();405 });406 test('should be able to customize pushToBaseBranch title', async () => {407 const options = testOptions();408 options.labels = [409 ...options.labels,410 {411 name: 'pushToBaseBranch',412 changelogTitle: 'Custom Title',413 description: 'N/A',414 releaseType: 'none'415 }416 ];417 const changelog = new Changelog(dummyLog(), options);418 changelog.loadDefaultHooks();419 const commits = await logParse.normalizeCommits([420 {421 hash: '1',422 files: [],423 authorName: 'Adam Dierkens',424 authorEmail: 'adam@dierkens.com',425 subject: 'I was a push to master\n\n',426 labels: ['pushToBaseBranch']427 },428 {429 hash: '2',430 files: [],431 authorName: 'Adam Dierkens',432 authorEmail: 'adam@dierkens.com',433 subject: 'First Feature (#1235)',434 labels: ['minor']435 }436 ]);437 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();438 });439 test('should omit changelog item for next branches', async () => {440 const options = testOptions();441 const changelog = new Changelog(dummyLog(), options);442 changelog.loadDefaultHooks();443 const commits = await logParse.normalizeCommits([444 {445 hash: '2',446 files: [],447 authorName: 'Adam Dierkens',448 authorEmail: 'adam@dierkens.com',449 subject: 'First Feature (#1235)',450 labels: ['minor']451 }452 ]);453 expect(454 await changelog.generateReleaseNotes([455 {456 ...commits[0],457 hash: '1',458 files: [],459 authorName: 'Adam Dierkens',460 authorEmail: 'adam@dierkens.com',461 subject: 'V8\n\n',462 labels: [''],463 pullRequest: {464 base: 'intuit/next',465 number: 123,466 body: '# Release Notes\n\nfoobar'467 }468 },469 ...commits470 ])471 ).toMatchSnapshot();472 });473 test('should be able to customize titles', async () => {474 const options = testOptions();475 options.labels = [476 ...options.labels,477 {478 name: 'Version: Minor',479 changelogTitle: 'Woo Woo New Features',480 description: 'N/A',481 releaseType: SEMVER.minor482 }483 ];484 const changelog = new Changelog(dummyLog(), options);485 changelog.loadDefaultHooks();486 const commits = await logParse.normalizeCommits([487 {488 hash: '2',489 files: [],490 authorName: 'Adam Dierkens',491 authorEmail: 'adam@dierkens.com',492 subject: 'First Feature (#1235)',493 labels: ['Version: Minor']494 }495 ]);496 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();497 });498 test('should merge sections with same changelog title', async () => {499 const options = testOptions();500 options.labels = [501 ...options.labels,502 {503 name: 'new-component',504 changelogTitle: 'Enhancement',505 releaseType: SEMVER.minor506 },507 {508 name: 'Version: Minor',509 changelogTitle: 'Enhancement',510 description: 'N/A',511 releaseType: SEMVER.minor512 }513 ];514 const changelog = new Changelog(dummyLog(), options);515 changelog.loadDefaultHooks();516 const commits = await logParse.normalizeCommits([517 {518 hash: '3',519 files: [],520 authorName: 'Adam Dierkens',521 authorEmail: 'adam@dierkens.com',522 subject: 'Second Feature (#1236)',523 labels: ['new-component']524 },525 {526 hash: '2',527 files: [],528 authorName: 'Adam Dierkens',529 authorEmail: 'adam@dierkens.com',530 subject: 'First Feature (#1235)',531 labels: ['Version: Minor']532 }533 ]);534 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();535 });536 test('should add additional release notes', async () => {537 const changelog = new Changelog(dummyLog(), testOptions());538 changelog.loadDefaultHooks();539 const commits = await logParse.normalizeCommits([540 {541 hash: '2',542 files: [],543 authorName: 'Adam Dierkens',544 authorEmail: 'adam@dierkens.com',545 subject: 'First Feature (#1235)',546 labels: ['minor']547 }548 ]);549 commits[0].pullRequest!.body = endent`550 # Why551 Some words552 ## Release Notes553 Here is how you upgrade554 ## Todo555 - [ ] add tests556 `;557 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();558 });559 test('additional release notes should be able to contain sub-headers', async () => {560 const changelog = new Changelog(dummyLog(), testOptions());561 changelog.loadDefaultHooks();562 const commits = await logParse.normalizeCommits([563 {564 hash: '2',565 files: [],566 authorName: 'Adam Dierkens',567 authorEmail: 'adam@dierkens.com',568 subject: 'First Feature (#1235)',569 labels: ['minor']570 }571 ]);572 commits[0].pullRequest!.body = endent`573 # Why574 Some words575 ## Release Notes576 Here is how you upgrade577 ### Things you should really know578 Bam!?579 ## Todo580 - [ ] add tests581 `;582 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();583 });584 test("doesn't add additional release notes when there are none", async () => {585 const changelog = new Changelog(dummyLog(), testOptions());586 changelog.loadDefaultHooks();587 const commits = await logParse.normalizeCommits([588 {589 hash: '2',590 files: [],591 authorName: 'Adam Dierkens',592 authorEmail: 'adam@dierkens.com',593 subject: 'First Feature (#1235)',594 labels: ['minor']595 }596 ]);597 commits[0].pullRequest!.body = endent`598 # Why599 Some words600 `;601 const res = await changelog.generateReleaseNotes(commits);602 expect(res).toMatchSnapshot();603 });604 test('additional release notes should omit renovate prs', async () => {605 const changelog = new Changelog(dummyLog(), testOptions());606 changelog.loadDefaultHooks();607 const commits = await logParse.normalizeCommits([608 {609 hash: '2',610 files: [],611 authorName: 'Adam Dierkens',612 authorEmail: 'adam@dierkens.com',613 subject: 'First Feature (#1235)',614 labels: ['minor']615 }616 ]);617 commits[0].authors[0].username = 'renovate-bot';618 commits[0].pullRequest!.body = endent`619 # Why620 Some words621 ## Release Notes622 Here is how you upgrade623 ### Things you should really know624 Bam!?625 ## Todo626 - [ ] add tests627 `;628 expect(await changelog.generateReleaseNotes(commits)).toMatchSnapshot();629 });630 test('additional release notes should have tappable omit', async () => {631 const changelog = new Changelog(dummyLog(), testOptions());632 changelog.loadDefaultHooks();633 changelog.hooks.omitReleaseNotes.tap('test', commit => {634 if (commit.labels.includes('no-notes')) {635 return true;636 }637 });638 const commits = await logParse.normalizeCommits([639 {640 hash: '2',641 files: [],642 authorName: 'Adam Dierkens',643 authorEmail: 'adam@dierkens.com',644 subject: 'First Feature (#1235)',645 labels: ['minor', 'no-notes']646 }647 ]);648 commits[0].pullRequest!.body = endent`649 # Why650 Some words651 ## Release Notes652 Here is how you upgrade...

Full Screen

Full Screen

index.ts

Source:index.ts Github

copy

Full Screen

1#!/usr/bin/env node2import { Log } from "./utils/log.util";3import { DefaultConfig, GatherConfig } from "./pipelines/GatherConfig";4import { GetCommitsSinceLatestVersion } from "./pipelines/get-commits-since-latest-version";5import { NormalizeCommits } from "./pipelines/normalize-commits";6import { ExitIfNoCommits } from "./pipelines/exit-if-no-commits";7import { ExitIfNoBumping } from "./pipelines/exit-if-no-bumping";8import { BuildNewVersion } from "./pipelines/build-new-version";9import { ApplyVersioning } from "./pipelines/apply-versioning";10GatherConfig.concat(GetCommitsSinceLatestVersion)11 .concat(NormalizeCommits)12 .concat(ExitIfNoCommits)13 .concat(BuildNewVersion)14 .concat(ExitIfNoBumping)15 .concat(ApplyVersioning)16 .process(DefaultConfig)17 .catch((e) => {18 Log.error(e);19 process.exit(1);...

Full Screen

Full Screen

commits.utils.ts

Source:commits.utils.ts Github

copy

Full Screen

1export const normalizeCommitsResponse = (response) => {2 if (!Array.isArray(response)) return response;3 return response.map(normalizeCommits);4};5const normalizeCommits = (commit) => {6 return {7 sha: commit.sha,8 commit: commit.commit,9 htmlURL: commit.html_url,10 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestCommits = require('./bestCommits.js');2var bestCommits = new BestCommits();3 {id: 'a', parents: ['b']},4 {id: 'b', parents: ['c']},5 {id: 'c', parents: ['d']},6 {id: 'd', parents: ['e']},7 {id: 'e', parents: ['f']},8 {id: 'f', parents: ['g']},9 {id: 'g', parents: ['h']},10 {id: 'h', parents: ['i']},11 {id: 'i', parents: ['j']},12 {id: 'j', parents: ['k']},13 {id: 'k', parents: ['l']},14 {id: 'l', parents: ['m']},15 {id: 'm', parents: ['n']},16 {id: 'n', parents: ['o']},17 {id: 'o', parents: ['p']},18 {id: 'p', parents: ['q']},19 {id: 'q', parents: ['r']},20 {id: 'r', parents: ['s']},21 {id: 's', parents: ['t']},22 {id: 't', parents: ['u']},23 {id: 'u', parents: ['v']},24 {id: 'v', parents: ['w']},25 {id: 'w', parents: ['x']},26 {id: 'x', parents: ['y']},27 {id: 'y', parents: ['z']},28 {id: 'z', parents: []}29];30var normalizedCommits = bestCommits.normalizeCommits(commits);31console.log(normalizedCommits);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestFit = require('./bestfit.js');2var bf = new BestFit();3 {x: 1, y: 2},4 {x: 2, y: 4},5 {x: 3, y: 6},6 {x: 4, y: 8}7];8 {x: 1, y: 1},9 {x: 2, y: 2},10 {x: 3, y: 3},11 {x: 4, y: 4}12];13var normalizedCommits = bf.normalizeCommits(commits, data);14console.log(normalizedCommits);15[ { x: 1, y: 1.5 },16 { x: 2, y: 3 },17 { x: 3, y: 4.5 },18 { x: 4, y: 6 } ]19var BestFit = require('./bestfit.js');20var bf = new BestFit();21 {x: 1, y: 2},22 {x: 2, y: 4},23 {x: 3, y: 6},24 {x: 4, y: 8}25];26 {x: 1, y: 1},27 {x: 2, y: 2},28 {x: 3, y: 3},29 {x: 4, y: 4}30];31var regression = bf.getRegression(data, commits);32console.log(regression);33{ slope: 2, intercept: 0 }34var BestFit = require('./bestfit.js');35var bf = new BestFit();36 {x: 1, y: 2},37 {x: 2, y: 4},38 {x: 3, y: 6},39 {x: 4, y: 8}40];41 {x: 1, y: 1},42 {x: 2, y: 2},43 {x: 3, y: 3

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestCommits = require('./BestCommits.js');2 {id: 1, message: 'first commit', parents: []},3 {id: 2, message: 'second commit', parents: [1]},4 {id: 3, message: 'third commit', parents: [2]},5 {id: 4, message: 'fourth commit', parents: [2]},6 {id: 5, message: 'fifth commit', parents: [4]},7 {id: 6, message: 'sixth commit', parents: [5]},8 {id: 7, message: 'seventh commit', parents: [6]},9 {id: 8, message: 'eighth commit', parents: [3, 7]},10 {id: 9, message: 'ninth commit', parents: [8]},11 {id: 10, message: 'tenth commit', parents: [8]}12];13var bestCommits = new BestCommits(commits);14var normalizedCommits = bestCommits.normalizeCommits();15console.log(normalizedCommits);16[ { id: 1, message: 'first commit', parents: [] },17 { id: 2, message: 'second commit', parents: [ 1 ] },18 { id: 3, message: 'third commit', parents: [ 2 ] },19 { id: 4, message: 'fourth commit', parents: [ 2 ] },20 { id: 5, message: 'fifth commit', parents: [ 4 ] },21 { id: 6, message: 'sixth commit', parents: [ 5 ] },22 { id: 7, message: 'seventh commit', parents: [ 6 ] },23 { id: 8, message: 'eighth commit', parents: [ 3, 7 ] },24 { id: 9, message: 'ninth commit', parents: [ 8 ] },25 { id: 10, message: 'tenth commit', parents: [ 8 ] } ]26var BestCommits = require('./BestCommits.js');27 {id: 1, message: 'first commit

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful