Closed hussainweb closed 1 year ago
How would a validate
command work? Would you type in the commit message, or would you tell it a file where the commit message exists?
If you want to type in the commit message when you validate it, I think the prepare
command works well for this.
Hmm... Yes, the commit message could come in via stdin. I must have missed that capability of prepare
to validate commit messages. I'll look again.
I am not able to find anything relevant in the prepare
command documentation. So, what I want to do is if the user has entered the commit message: "fix: some fix in module", conventional-commits
should return exit code 0. I don't see any such explanation in the usage of the prepare
command. Am I missing something?
❯ ./bin/conventional-commits.phar prepare --help
Description:
Prepares a commit message conforming to Conventional Commits
Usage:
prepare [options]
Options:
--config=CONFIG Path to a file containing Conventional Commits configuration
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
This command interactively helps prepare a commit message according to the Conventional Commits specification. For more information, see https://www.conventionalcommits.org.
When you run the command, it walks the user through the prompts to create the commit message. The user enters each part of the message, which is validated.
Ah, that's not what I mean. I wanted to replicate the functionality provided by the ValidateConventionalCommit
. That only works for CaptainHook right now but as I described originally, I wanted to make that available to GrumPHP. One easy way to do that is by making it available in the executable so that I can call it from GrumPHP. I had described this in the original post in #25.
In other words, what I am looking for is a way where I can pass a commit message string to conventional-commits
and it would tell me if that is a valid commit message or not. As explained before, I couldn't find a way to do this with the CLI.
I think I understand now. You would like to be able to pipe a message to a validate
command on stdin—not have a user type it in from stdin.
There's currently no way to do this with the CLI, and I'm open to a PR for this. 😄
Awesome and thanks for the discussion. I'll work on a PR in the coming days.
How do I validate a commit message using the executable instead of CaptainHook?
While working on #40, I realized that even if there is a PHAR, I can't use it to actually validate a commit message. These are the only commands I see on the executable and none of them help in validating a message.
I think there is a place for a new command
validate
that would do the job. I am happy to write a PR but I wanted to check if I have not missed something obvious here.