Skip to content

Restrict list of types / scopes #24

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

Closed
waghanza opened this issue May 9, 2019 · 3 comments
Closed

Restrict list of types / scopes #24

waghanza opened this issue May 9, 2019 · 3 comments

Comments

@waghanza
Copy link

waghanza commented May 9, 2019

Hi @woile,

Thanks you for this awesome project.

It really let developers (at least me) focusing on code.

However, I have a little suggestion. I see (in https://woile.github.io/commitizen/config/) that we can specify the format to use.

It could be a great feature (at least for private project) to have an option to specify

  • types allowed
  • scope

What do you think ?

PS : It's more to avoid errors (keeping a flexibility) than restricts

@woile
Copy link
Member

woile commented May 10, 2019

Hey I'm glad you like it! Thanks for the kind words.

Regarding the type and scope. If I understand correct you'd like to use format like:

v$minor.$major.$path-$scope-$type

The problem with this approach is that you might have more than one commit between versions, so it doesn't make much sense to specify a tag with information of one of those commits, I think it would be quite confusing. What do you think?

@waghanza
Copy link
Author

Hi,

I think I wasn't clear enough. In fact I'm talking about commit messages.

As conventional commit specifications explain, there could be a scope, an optional one.

In some projects, there could be a list of pre-defined scopes (as long as a pre-defined list of types).

What I had suggested is to have them into .cz file, as long as we can define per repo standard.

I hope to be clearer this time

@woile
Copy link
Member

woile commented May 10, 2019

Oh sorry, I completely misunderstood it haha.

Ideally this should be done using a custom rule

you could even inherit from ConventionalCommitsCz

from commitizen.cz.conventional_commits import ConventionalCommitsCz

class ConventionalCommitsScope(ConventionalCommitsCz):
    def questions(self) -> list:
        questions = super().questions()
        questions[2] = {
                "type": "list",
                "name": "scope",
                "message": "Choose your scope",
                "choices": [
                    {
                        "value": "mysuperscope",
                        "name": "this is a crazy scope"
                    }
                ]
        }
       return questions

discover_this = ConventionalCommitsScope

You can read more in the link provided on how to create the setup.py file.

I think that would solve your problem in the short term.

Regarding providing a configuration I will try to come up with something. I don't think those values should be part of the global config, because you can write your own commit rules and scope and type would stop having meaning in the context of your custom rule (different to conventional commits).

But maybe, there should be a way to customize your current rule through configuration.

[tool.commitizen.rule-conf.scope]
type = "list"
name = "scope"
message = "Choose your scope"
choices = [{"value": "mysuperscope","name": "this is a crazy scope"}]

It would be nice to brainstorm ideas on how to do it. Specially on how to express that if you are not using the toml configuration, but the normal ConfigParser.

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

No branches or pull requests

2 participants