Skip to content

Restrict list of types / scopes #24

Closed

Description

@waghanza

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

Activity

  1. woile commented on May 10, 2019

    @woile
    Member

    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?

  2. waghanza commented on May 10, 2019

    @waghanza
    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

  3. woile commented on May 10, 2019

    @woile
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions