Skip to content

Conversation

@ze0ne
Copy link

@ze0ne ze0ne commented Apr 30, 2025

feat: add excludeFromCommitMsg option for additionalQuestions

Description

This PR introduces a new excludeFromCommitMsg predicate on each entry in additionalQuestions. When defined, it allows users to conditionally omit certain answers from the generated commit message body based on the full set of answers provided.


Motivation and Context

By default, all answers to additionalQuestions are appended to the commit body. However, in cases where an answer is used solely to trigger the display of another question—without itself being meaningful in the final commit—you may want to collect it during the prompt phase but omit it from the resulting commit message. The excludeFromCommitMsg callback lets you conditionally exclude those fields at commit-generation time:

additionalQuestions: [
  {
    name: 'internalNotes',
    mapping: 'Notes:',
    // only include if the user explicitly opts in
    excludeFromCommitMsg: answers => !answers.includeInternalNotes,
  }
]

Changes

API

Added optional excludeFromCommitMsg?: (answers) => boolean to each additionalQuestions entry.

Behavior

  • For each question with an excludeFromCommitMsg function, we now call it with the full answers object.
  • If it returns true, that particular mapping + answer pair is not appended to the commit message body.

Tests

Added two new unit tests covering both inclusion and exclusion paths.

Docs

Updated README to document the excludeFromCommitMsg option and include a usage example.

@ze0ne ze0ne changed the title Feature/exclude answer feat: add excludeFromCommitMsg option for additionalQuestions Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant