Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I validate a commit message using the executable instead of CaptainHook? #57

Closed
hussainweb opened this issue Jul 19, 2022 · 8 comments
Labels
question Further information is requested

Comments

@hussainweb
Copy link
Contributor

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.

  completion  Dump the shell completion script
  config      Configures options for creating Conventional Commits
  help        Display help for a command
  list        List commands
  prepare     Prepares a commit message conforming to Conventional Commits

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.

@hussainweb hussainweb added the question Further information is requested label Jul 19, 2022
@ramsey
Copy link
Owner

ramsey commented Jul 21, 2022

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.

@hussainweb
Copy link
Contributor Author

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.

@hussainweb
Copy link
Contributor Author

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.

@ramsey
Copy link
Owner

ramsey commented Jul 21, 2022

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.

@hussainweb
Copy link
Contributor Author

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.

@hussainweb
Copy link
Contributor Author

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.

@ramsey
Copy link
Owner

ramsey commented Jul 21, 2022

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. 😄

@hussainweb
Copy link
Contributor Author

Awesome and thanks for the discussion. I'll work on a PR in the coming days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants