Closed Ibochkarev closed 2 months ago
Sorry for the delayed response.
First, this commit message does not comply with the Conventional Commits specification, so it will not be included as a feature.
However, it can be completed with full custom configuration: https://cz-git.qbb.sh/config/engineer#formatmessagecb https://cz-git.qbb.sh/recipes/default-issues
commitlint.config.cjs
const { execSync } = require('node:child_process')
const issue = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim()
.split('_')?.[1] || '0'
const mapping = (type) => {
const removeAnsi = type.replace(/\x1b\[[0-9;]*m/g, '')
return {
feat: 'functionality',
}[removeAnsi]
}
const pusher = execSync('git config user.name || true').toString().trim()
/** @type {import('czg').UserConfig} */
module.exports = {
prompt: {
scopes: ['infrastructure'],
customScopesAlign: 'bottom',
skipQuestions: ['body', 'breaking'],
allowCustomIssuePrefix: false,
allowEmptyIssuePrefix: false,
issuePrefixes: ['by'],
defaultIssues: pusher,
messages: {
footer: 'The author of this commit is:\n',
},
formatMessageCB: ({ type, scope, subject, footer }) => {
// console.log(type)
return `${type}(${scope}) ${mapping(type)}: [PREMPROD-${issue}] ${subject} by ${footer.trim()}`
},
},
}
Using formatMessageCB
, you can create any commit message format you want.The information can be obtained from the command or Node library in the JS file.
💭 Describe the feature
Thanks for the development of the project!
I need to add the branch name to the commit name. Is it possible to automate the process of inserting a branch name into a commit by introducing a new parameter.
Example of a commit name after adding
feat(infrastructure) functionality: [PREMPROD-30287] Refine git branch detection by mask
Thanks in advance!
💡 Proposed Solution
No response