{"id":23170261,"url":"https://github.com/mrchief/conventional-commits-pattern-filter","last_synced_at":"2025-04-04T23:15:14.569Z","repository":{"id":44115458,"uuid":"194745322","full_name":"mrchief/conventional-commits-pattern-filter","owner":"mrchief","description":"Filter commits by pattern, not just reverted ones","archived":false,"fork":false,"pushed_at":"2023-01-04T02:53:29.000Z","size":768,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T07:42:31.772Z","etag":null,"topics":["commits","conventional","conventional-changelog","conventional-commits","filter"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrchief.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-01T21:28:45.000Z","updated_at":"2019-07-02T20:35:45.000Z","dependencies_parsed_at":"2023-02-01T18:01:52.939Z","dependency_job_id":null,"html_url":"https://github.com/mrchief/conventional-commits-pattern-filter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"mrchief/npm-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Fconventional-commits-pattern-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Fconventional-commits-pattern-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Fconventional-commits-pattern-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Fconventional-commits-pattern-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrchief","download_url":"https://codeload.github.com/mrchief/conventional-commits-pattern-filter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261603,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commits","conventional","conventional-changelog","conventional-commits","filter"],"created_at":"2024-12-18T03:26:28.366Z","updated_at":"2025-04-04T23:15:14.532Z","avatar_url":"https://github.com/mrchief.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# conventional-commits-pattern-filter\n\nFilter commits by pattern, not just reverted ones.\n\n[![npm bundle size][bsbadgeimgurl]][bsurl] [![npm][npmbadgeimgurl]][npmurl]\n\n[bsurl]: https://bundlephobia.com/result?p=conventional-commits-pattern-filter\n[bsbadgeimgurl]: https://img.shields.io/bundlephobia/minzip/conventional-commits-pattern-filter.svg\n[npmurl]: https://www.npmjs.com/package/conventional-commits-pattern-filter\n[npmbadgeimgurl]: https://img.shields.io/npm/v/conventional-commits-pattern-filter.svg\n\n## Why\n\n[conventional-commits-filter](https://www.npmjs.com/package/conventional-commits-filter) filters reverted commits. **conventional-commits-pattern-filter** extends that ability to filter out arbitrary commits based on user defined patterns.\n\n### Use case - filtering out another app's commits\n\nLet's say you have one codebase that is shared by many frontend apps. These apps have different deployments but commit changes to the same, git repo. E.g., consider this history:\n\n```\n\u003c-- app1 wants to release a new version -- \u003e\n\n|\no feat: [app1]: Awesome new feature\n|\no fix: [app1]: Fixed that annoying bug\n|\no fix: [app2]: Squashed that bug\n|\no docs: [app2]: Added awesome documentation\n|\no chore: [app1]: Bump version for abc dependency\n|\n\n\u003c-- app1 released v1.5.9 -- \u003e\n```\n\nIn order to create a new release, `app1` wants to include all changes tagged with `[app1]` since `v1.5.9` release. With **conventional-commits-pattern-filter**, it can do so:\n\n```\nconst allCommits = conventionalCommitsParser(...)  // get commits parsed via conventional-commits-parser\n\nconst appCommits = filter({commits: allCommits, field: 'subject', pattern: '[app2]' })\n\n// appCommits\n\no feat: [app1]: Awesome new feature\n|\no fix: [app1]: Fixed that annoying bug\n|\no chore: [app1]: Bump version for abc dependency\n```\n\n### Use case - filtering out BREAKING CHANGES\n\nSay you want to extract breaking changes only so that you can share it with stakeholders or do something else with them.\n\n```\nconst breakingChanges = filter({ commits, field: 'body', pattern: /^((?!BREAKING CHANGE).)*/igm })\n```\n\nAlternatively, if negative lookahead is not your thing, you can use the `include` flag to include matching commits:\n\n```\nconst breakingChanges = filter({ commits, field: 'body', pattern: /BREAKING CHANGE/igm, include: true })\n```\n\n## Install\n\n```\nnpm i conventional-commits-filter\n```\n\n## Usage\n\n```\nconst filter = require('conventional-commits-pattern-filter')\n\n// given a commits array like\nconst commits = [\n  {\n    subject: 'feat: [excludeMe]: some feature',\n    // other props\n  },\n  {\n    subject: 'feat: thw best thing since sliced bread',\n    // other props\n  },\n]\n\nconst filteredCommits = filter({ commits, field: 'subject', pattern: '[excludeMe]' })\n\n// filteredCommits\n[\n    {\n        subject: 'feat: thw best thing since sliced bread',\n        // other props\n    }\n]\n```\n\n## API\n\n### conventionalCommitsPatternFilter(options)\n\nReturns a filtered array of commits based on the given field and pattern.\n\n### options\n\nType: `object`\n\n#### commits\n\nType: `array`\n\nArray of parsed commits returned by [conventional-commits-parser](https://www.npmjs.com/package/conventional-commits-parser)\n\nThe `commit` object has the following structure:\n\n```\n{ type: 'feat',\n  scope: 'scope',\n  subject: 'what an amazing feature',\n  merge: null,\n  header: 'feat(scope): what an amazing feature',\n  body: null,\n  footer: 'Closes #1',\n  notes: [],\n  references:\n   [ { action: 'Closes',\n       owner: null,\n       repository: null,\n       issue: '1',\n       raw: '#1',\n       prefix: '#' } ],\n  mentions: [],\n  revert: null }\n```\n\n#### field\n\nType: `string` or `array`\n\nField(s) to filter on. Can be the name of any valid property/key on the `commit` object from `commits` array.\n\n```\nfilter({ commits, field: ['subject', 'body'], pattern: '[excludeMe]' })\n```\n\nNote: Currently only supports simple properties. Send me a PR if you need any deep filtering!\n\n#### pattern\n\nType: `string` or `regex`\n\nThe pattern to filter commits. Any matching commit will be excluded.\n\n#### include\n\nType: `boolean`\n\nIf true, **includes** matching commits instead of excluding them.\n\n## License\n\n![NPM](https://img.shields.io/npm/l/conventional-commits-pattern-filter.svg)\nReleased 2019 by [Hrusikesh Panda](https://github.com/mrchief)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrchief%2Fconventional-commits-pattern-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrchief%2Fconventional-commits-pattern-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrchief%2Fconventional-commits-pattern-filter/lists"}