commit-analyzer icon indicating copy to clipboard operation
commit-analyzer copied to clipboard

using custom commit types

Open Clumsy-Coder opened this issue 4 years ago β€’ 5 comments

is there a way to use custom commit types?

Ex: dep-add(npm): :heavy_plus_sign: add cz-emoji npm package config(semantic-release): :wrench: add @semantic-release/analyze-commits plugin

dep-add(npm): :heavy_plus_sign: add cz-emoji npm package config(semantic-release): :wrench: add @semantic-release/analyze-commits plugin

other commit types cz-emoji

Clumsy-Coder avatar Aug 18 '20 14:08 Clumsy-Coder

Using the commit from example and semantic-release config, only commit type config result in patch release. dep-add commit type doesn't result in patch release.

Ex: dep-add(npm): :heavy_plus_sign: add cz-emoji npm package config(semantic-release): :wrench: add @semantic-release/analyze-commits plugin

dep-add(npm): βž• add cz-emoji npm package config(semantic-release): πŸ”§ add @semantic-release/analyze-commits plugin

.releaserc.js

const commitTypes = require("./semantic-release/commitTypes.js");
const commitRules = require("./semantic-release/commitRules.js");

module.exports = {
  tagFormat: "${version}",
  branches: ["master"],
  plugins: [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
  ],
  preset: "conventionalcommits",
  analyzeCommits: {
    releaseRules: commitRules,
  },
  presetConfig: {
    types: commitTypes,
  },
};

semantic-release/commitRules.js

/* eslint-disable indent */
const MAJOR = "major";
const MINOR = "minor";
const PATCH = "patch";

module.exports = [
  { breaking: true, release: MAJOR },
  { revert: true, release: PATCH },
  {
    // emoji: '🎨',
    type: "style",
    // code: ':art:',
    // description: 'Improving structure / format of the code.',
    release: PATCH,
  },
  {
    // emoji: '⚑️',
    type: "perf",
    // code: ':zap:',
    // description: 'Improving performance.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ”₯',
    type: "prune",
    // code: ':fire:',
    // description: 'Removing code or files.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ›',
    type: "fix",
    // code: ':bug:',
    // description: 'Fixing a bug.',
    release: PATCH,
  },
  {
    // emoji: 'πŸš‘',
    type: "quickfix",
    // code: ':ambulance:',
    // description: 'Critical hotfix.',
    release: MINOR,
  },
  {
    // emoji: '✨',
    type: "feature",
    // code: ':sparkles:',
    // description: 'Introducing new features.',
    release: MINOR,
  },
  {
    // emoji: 'πŸ“',
    type: "docs",
    // code: ':pencil:',
    // description: 'Writing docs.',
    release: false,
  },
  {
    // emoji: 'πŸš€',
    type: "deploy",
    // code: ':rocket:',
    // description: 'Deploying stuff.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ’„',
    type: "ui",
    // code: ':lipstick:',
    // description: 'Updating the UI and style files.',
    release: PATCH,
  },
  {
    // emoji: 'πŸŽ‰',
    type: "init",
    // code: ':tada:',
    // description: 'Initial commit.',
    release: PATCH,
  },
  {
    // emoji: 'βœ…',
    type: "test",
    // code: ':white_check_mark:',
    // description: 'Adding tests.',
    release: false,
  },
  {
    // emoji: 'πŸ”’',
    type: "security",
    // code: ':lock:',
    // description: 'Fixing security issues.',
    release: MINOR,
  },
  {
    // emoji: '🍎',
    type: "osx",
    // code: ':apple:',
    // description: 'Fixing something on macOS.',
    release: PATCH,
  },
  {
    // emoji: '🐧',
    type: "linux",
    // code: ':penguin:',
    // description: 'Fixing something on Linux.',
    release: PATCH,
  },
  {
    // emoji: '🏁',
    type: "windows",
    // code: ':checkered_flag:',
    // description: 'Fixing something on Windows.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ€–',
    type: "android",
    // code: ':robot:',
    // description: 'Fixing something on Android.',
    release: PATCH,
  },
  {
    // emoji: '🍏',
    type: "ios",
    // code: ':green_apple:',
    // description: 'Fixing something on iOS.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ”–',
    type: "release",
    // code: ':bookmark:',
    // description: 'Releasing / Version tags.',
    release: PATCH,
  },
  {
    // emoji: '🚨',
    type: "lint",
    // code: ':rotating_light:',
    // description: 'Removing linter warnings.',
    release: PATCH,
  },
  {
    // emoji: '🚧',
    type: "wip",
    // code: ':construction:',
    // description: 'Work in progress.',
    release: false, // don't create a release
  },
  {
    // emoji: 'πŸ’š',
    type: "fix-ci",
    // code: ':green_heart:',
    // description: 'Fixing CI Build.',
    release: PATCH,
  },
  {
    // emoji: '⬇️',
    type: "downgrade",
    // code: ':arrow_down:',
    // description: ' Downgrading dependencies.',
    release: PATCH,
  },
  {
    // emoji: '⬆️',
    type: "upgrade",
    // code: ':arrow_up:',
    // description: ' Upgrading dependencies.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ“Œ',
    type: "pushpin",
    // code: ':pushpin:',
    // description: 'Pinning dependencies to specific versions.',
    release: false,
  },
  {
    // emoji: 'πŸ‘·',
    type: "ci",
    // code: ':construction_worker:',
    // description: 'Adding CI build system.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ“ˆ',
    type: "analytics",
    // code: ':chart_with_upwards_trend:',
    // description: 'Adding analytics or tracking code.',
    release: PATCH,
  },
  {
    // emoji: '♻️',
    type: "refactoring",
    // code: ':recycle:',
    // description: ' Refactoring code.',
    release: MINOR,
  },
  {
    // emoji: '🐳',
    type: "docker",
    // code: ':whale:',
    // description: 'Work about Docker.',
    release: PATCH,
  },
  {
    // emoji: 'βž•',
    type: "dep-add",
    // code: ':heavy_plus_sign:',
    // description: 'Adding a dependency.',
    release: PATCH,
  },
  {
    // emoji: 'βž–',
    type: "dep-rm",
    // code: ':heavy_minus_sign:',
    // description: 'Removing a dependency.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ”§',
    type: "config",
    // code: ':wrench:',
    // description: 'Changing configuration files.',
    release: PATCH,
  },
  {
    // emoji: '🌐',
    type: "i18n",
    // code: ':globe_with_meridians:',
    // description: 'Internationalization and localization.',
    release: PATCH,
  },
  {
    // emoji: '✏️',
    type: "typo",
    // code: ':pencil2:',
    // description: ' Fixing typos.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ’©',
    type: "poo",
    // code: ':poop:',
    // description: 'Writing bad code that needs to be improved.',
    release: PATCH,
  },
  {
    // emoji: 'βͺ',
    type: "revert",
    // code: ':rewind:',
    // description: 'Reverting changes.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ”€',
    type: "merge",
    // code: ':twisted_rightwards_arrows:',
    // description: 'Merging branches.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ“¦',
    type: "dep-up",
    // code: ':package:',
    // description: 'Updating compiled files or packages.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ‘½',
    type: "compat",
    // code: ':alien:',
    // description: 'Updating code due to external API changes.',
    release: PATCH,
  },
  {
    // emoji: '🚚',
    type: "mv",
    // code: ':truck:',
    // description: 'Moving or renaming files.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ“„',
    type: "license",
    // code: ':page_facing_up:',
    // description: 'Adding or updating license.',
    release: false,
  },
  {
    // emoji: 'πŸ’₯',
    type: "breaking",
    // code: ':boom:',
    // description: 'Introducing breaking changes.',
    release: MAJOR,
  },
  {
    // emoji: '🍱',
    type: "assets",
    // code: ':bento:',
    // description: 'Adding or updating assets.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ‘Œ',
    type: "review",
    // code: ':ok_hand:',
    // description: 'Updating code due to code review changes.',
    release: PATCH,
  },
  {
    // emoji: '♿️',
    type: "access",
    // code: ':wheelchair:',
    // description: 'Improving accessibility.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ’‘',
    type: "docs-code",
    // code: ':bulb:',
    // description: 'Documenting source code.',
    release: PATCH,
  },
  {
    // emoji: '🍻',
    type: "beer",
    // code: ':beers:',
    // description: 'Writing code drunkenly.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ’¬',
    type: "texts",
    // code: ':speech_balloon:',
    // description: 'Updating text and literals.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ—ƒ',
    type: "db",
    // code: ':card_file_box:',
    // description: ' Performing database related changes.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ”Š',
    type: "log-add",
    // code: ':loud_sound:',
    // description: 'Adding logs.',
    release: false,
  },
  {
    // emoji: 'πŸ”‡',
    type: "log-rm",
    // code: ':mute:',
    // description: 'Removing logs.',
    release: false,
  },
  {
    // emoji: 'πŸ‘₯',
    type: "contrib-add",
    // code: ':busts_in_silhouette:',
    // description: 'Adding contributor(s).',
    release: false,
  },
  {
    // emoji: '🚸',
    type: "ux",
    // code: ':children_crossing:',
    // description: 'Improving user experience / usability.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ—',
    type: "arch",
    // code: ':building_construction:',
    // description: ' Making architectural changes.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ“±',
    type: "iphone",
    // code: ':iphone:',
    // description: 'Working on responsive design.',
    release: PATCH,
  },
  {
    // emoji: '🀑',
    type: "clown-face",
    // code: ':clown_face:',
    // description: 'Mocking things.',
    release: false,
  },
  {
    // emoji: 'πŸ₯š',
    type: "egg",
    // code: ':egg:',
    // description: 'Adding an easter egg.',
    release: PATCH,
  },
  {
    // emoji: 'πŸ™ˆ',
    type: "see-no-evil",
    // code: ':see_no_evil:',
    // description: 'Adding or updating a .gitignore file',
    release: false,
  },
  {
    // emoji: 'πŸ“Έ',
    type: "camera-flash",
    // code: ':camera_flash:',
    // description: 'Adding or updating snapshots',
    release: false,
  },
  {
    // emoji: 'βš—',
    type: "experiment",
    // code: ':alembic:',
    // description: ' Experimenting new things',
    release: false,
  },
  {
    // emoji: 'πŸ”',
    type: "seo",
    // code: ':mag:',
    // description: 'Improving SEO',
    release: PATCH,
  },
  {
    // emoji: '☸️',
    type: "k8s",
    // code: ':wheel_of_dharma:',
    // description: ' Work about Kubernetes',
    release: PATCH,
  },
  {
    // emoji: '🏷️',
    type: "types",
    // code: ':label:',
    // description: ' Adding or updating types (Flow, TypeScript)',
    release: PATCH,
  },
  {
    // emoji: '🌱',
    type: "seed",
    // code: ':seedling:',
    // description: 'Adding or updating seed files',
    release: PATCH,
  },
  {
    // emoji: '🚩',
    type: "flags",
    // code: ':triangular_flag_on_post:',
    // description: 'Adding, updating, or removing feature flags',
    release: PATCH,
  },
  {
    // emoji: 'πŸ’«',
    type: "animation",
    // code: ':dizzy:',
    // description: 'Adding or updating animations and transitions',
    release: PATCH,
  },
];

semantic-release/commitTypes.js

/* eslint-disable indent */
module.exports = [
  {
    // emoji: '🎨',
    // code: ':art:',
    section: "Improving structure / format of the code.",
    type: "style",
  },
  {
    // emoji: '⚑️',
    // code: ':zap:',
    section: "Improving performance.",
    type: "perf",
  },
  {
    // emoji: 'πŸ”₯',
    // code: ':fire:',
    section: "Removing code or files.",
    type: "prune",
  },
  {
    // emoji: 'πŸ›',
    // code: ':bug:',
    section: "Fixing a bug.",
    type: "fix",
  },
  {
    // emoji: 'πŸš‘',
    // code: ':ambulance:',
    section: "Critical hotfix.",
    type: "quickfix",
  },
  {
    // emoji: '✨',
    // code: ':sparkles:',
    section: "Introducing new features.",
    type: "feature",
  },
  {
    // emoji: 'πŸ“',
    // code: ':pencil:',
    section: "Writing docs.",
    type: "docs",
  },
  {
    // emoji: 'πŸš€',
    // code: ':rocket:',
    section: "Deploying stuff.",
    type: "deploy",
  },
  {
    // emoji: 'πŸ’„',
    // code: ':lipstick:',
    section: "Updating the UI and style files.",
    type: "ui",
  },
  {
    // emoji: 'πŸŽ‰',
    // code: ':tada:',
    section: "Initial commit.",
    type: "init",
  },
  {
    // emoji: 'βœ…',
    // code: ':white_check_mark:',
    section: "Adding tests.",
    type: "test",
  },
  {
    // emoji: 'πŸ”’',
    // code: ':lock:',
    section: "Fixing security issues.",
    type: "security",
  },
  {
    // emoji: '🍎',
    // code: ':apple:',
    section: "Fixing something on macOS.",
    type: "osx",
  },
  {
    // emoji: '🐧',
    // code: ':penguin:',
    section: "Fixing something on Linux.",
    type: "linux",
  },
  {
    // emoji: '🏁',
    // code: ':checkered_flag:',
    section: "Fixing something on Windows.",
    type: "windows",
  },
  {
    // emoji: 'πŸ€–',
    // code: ':robot:',
    section: "Fixing something on Android.",
    type: "android",
  },
  {
    // emoji: '🍏',
    // code: ':green_apple:',
    section: "Fixing something on iOS.",
    type: "ios",
  },
  {
    // emoji: 'πŸ”–',
    // code: ':bookmark:',
    section: "Releasing / Version tags.",
    type: "release",
  },
  {
    // emoji: '🚨',
    // code: ':rotating_light:',
    section: "Removing linter warnings.",
    type: "lint",
  },
  {
    // emoji: '🚧',
    // code: ':construction:',
    section: "Work in progress.",
    type: "wip",
  },
  {
    // emoji: 'πŸ’š',
    // code: ':green_heart:',
    section: "Fixing CI Build.",
    type: "fix-ci",
  },
  {
    // emoji: '⬇️',
    // code: ':arrow_down:',
    section: " Downgrading dependencies.",
    type: "downgrade",
  },
  {
    // emoji: '⬆️',
    // code: ':arrow_up:',
    section: " Upgrading dependencies.",
    type: "upgrade",
  },
  {
    // emoji: 'πŸ“Œ',
    // code: ':pushpin:',
    section: "Pinning dependencies to specific versions.",
    type: "pushpin",
  },
  {
    // emoji: 'πŸ‘·',
    // code: ':construction_worker:',
    section: "Adding CI build system.",
    type: "ci",
  },
  {
    // emoji: 'πŸ“ˆ',
    // code: ':chart_with_upwards_trend:',
    section: "Adding analytics or tracking code.",
    type: "analytics",
  },
  {
    // emoji: '♻️',
    // code: ':recycle:',
    section: " Refactoring code.",
    type: "refactoring",
  },
  {
    // emoji: '🐳',
    // code: ':whale:',
    section: "Work about Docker.",
    type: "docker",
  },
  {
    // emoji: 'βž•',
    // code: ':heavy_plus_sign:',
    section: "Adding a dependency.",
    type: "dep-add",
  },
  {
    // emoji: 'βž–',
    // code: ':heavy_minus_sign:',
    section: "Removing a dependency.",
    type: "dep-rm",
  },
  {
    // emoji: 'πŸ”§',
    // code: ':wrench:',
    section: "Changing configuration files.",
    type: "config",
  },
  {
    // emoji: '🌐',
    // code: ':globe_with_meridians:',
    section: "Internationalization and localization.",
    type: "i18n",
  },
  {
    // emoji: '✏️',
    // code: ':pencil2:',
    section: " Fixing typos.",
    type: "typo",
  },
  {
    // emoji: 'πŸ’©',
    // code: ':poop:',
    section: "Writing bad code that needs to be improved.",
    type: "poo",
  },
  {
    // emoji: 'βͺ',
    // code: ':rewind:',
    section: "Reverting changes.",
    type: "revert",
  },
  {
    // emoji: 'πŸ”€',
    // code: ':twisted_rightwards_arrows:',
    section: "Merging branches.",
    type: "merge",
  },
  {
    // emoji: 'πŸ“¦',
    // code: ':package:',
    section: "Updating compiled files or packages.",
    type: "dep-up",
  },
  {
    // emoji: 'πŸ‘½',
    // code: ':alien:',
    section: "Updating code due to external API changes.",
    type: "compat",
  },
  {
    // emoji: '🚚',
    // code: ':truck:',
    section: "Moving or renaming files.",
    type: "mv",
  },
  {
    // emoji: 'πŸ“„',
    // code: ':page_facing_up:',
    section: "Adding or updating license.",
    type: "license",
  },
  {
    // emoji: 'πŸ’₯',
    // code: ':boom:',
    section: "Introducing breaking changes.",
    type: "breaking",
  },
  {
    // emoji: '🍱',
    // code: ':bento:',
    section: "Adding or updating assets.",
    type: "assets",
  },
  {
    // emoji: 'πŸ‘Œ',
    // code: ':ok_hand:',
    section: "Updating code due to code review changes.",
    type: "review",
  },
  {
    // emoji: '♿️',
    // code: ':wheelchair:',
    section: "Improving accessibility.",
    type: "access",
  },
  {
    // emoji: 'πŸ’‘',
    // code: ':bulb:',
    section: "Documenting source code.",
    type: "docs-code",
  },
  {
    // emoji: '🍻',
    // code: ':beers:',
    section: "Writing code drunkenly.",
    type: "beer",
  },
  {
    // emoji: 'πŸ’¬',
    // code: ':speech_balloon:',
    section: "Updating text and literals.",
    type: "texts",
  },
  {
    // emoji: 'πŸ—ƒ',
    // code: ':card_file_box:',
    section: " Performing database related changes.",
    type: "db",
  },
  {
    // emoji: 'πŸ”Š',
    // code: ':loud_sound:',
    section: "Adding logs.",
    type: "log-add",
  },
  {
    // emoji: 'πŸ”‡',
    // code: ':mute:',
    section: "Removing logs.",
    type: "log-rm",
  },
  {
    // emoji: 'πŸ‘₯',
    // code: ':busts_in_silhouette:',
    section: "Adding contributor(s).",
    type: "contrib-add",
  },
  {
    // emoji: '🚸',
    // code: ':children_crossing:',
    section: "Improving user experience / usability.",
    type: "ux",
  },
  {
    // emoji: 'πŸ—',
    // code: ':building_construction:',
    section: " Making architectural changes.",
    type: "arch",
  },
  {
    // emoji: 'πŸ“±',
    // code: ':iphone:',
    section: "Working on responsive design.",
    type: "iphone",
  },
  {
    // emoji: '🀑',
    // code: ':clown_face:',
    section: "Mocking things.",
    type: "clown-face",
  },
  {
    // emoji: 'πŸ₯š',
    // code: ':egg:',
    section: "Adding an easter egg.",
    type: "egg",
  },
  {
    // emoji: 'πŸ™ˆ',
    // code: ':see_no_evil:',
    section: "Adding or updating a .gitignore file",
    type: "see-no-evil",
  },
  {
    // emoji: 'πŸ“Έ',
    // code: ':camera_flash:',
    section: "Adding or updating snapshots",
    type: "camera-flash",
  },
  {
    // emoji: 'βš—',
    // code: ':alembic:',
    section: " Experimenting new things",
    type: "experiment",
  },
  {
    // emoji: 'πŸ”',
    // code: ':mag:',
    section: "Improving SEO",
    type: "seo",
  },
  {
    // emoji: '☸️',
    // code: ':wheel_of_dharma:',
    section: " Work about Kubernetes",
    type: "k8s",
  },
  {
    // emoji: '🏷️',
    // code: ':label:',
    section: " Adding or updating types (Flow, TypeScript)",
    type: "types",
  },
  {
    // emoji: '🌱',
    // code: ':seedling:',
    section: "Adding or updating seed files",
    type: "seed",
  },
  {
    // emoji: '🚩',
    // code: ':triangular_flag_on_post:',
    section: "Adding, updating, or removing feature flags",
    type: "flags",
  },
  {
    // emoji: 'πŸ’«',
    // code: ':dizzy:',
    section: "Adding or updating animations and transitions",
    type: "animation",
  },
];

Clumsy-Coder avatar Aug 18 '20 15:08 Clumsy-Coder

I am also looking for a custom type configuration, Is it working?

LakshmiRavali avatar Sep 29 '21 07:09 LakshmiRavali

Looking for the same!

SalahAdDin avatar Mar 19 '24 15:03 SalahAdDin

Since this is already 4 years old, and no response is given, I take it is currently not possible to achieve this?

We already have fixed commit-message rules in out gitlab projects using regular expressions (we must have a JIRA ticket number as prefix), so I would like to have "^[Ticket-Number] [Commit-Type].*$".

patrickjane avatar Mar 25 '24 07:03 patrickjane

Since this is already 4 years old, and no response is given, I take it is currently not possible to achieve this?

We already have fixed commit-message rules in out gitlab projects using regular expressions (we must have a JIRA ticket number as prefix), so I would like to have "^[Ticket-Number] [Commit-Type].*$".

Similar to us:

const parserOpts = {
  headerPattern: /^(?:\[([A-z]*-\d+)]\s)?(\w*)(?:\((.*)\))?!?:\s(.*)$/,
  headerCorrespondence: ["ticket", "type", "scope", "subject"],
};

SalahAdDin avatar Mar 25 '24 14:03 SalahAdDin