Skip to content

New command: cz init #57

Description

@woile

Goal

Make it easier for users to use commitizen

Description

Let's suppose we have an already existing repo without commitizen.
The user types cz init and we try to be smart and detect some information:

  1. Find last tag and ask if that is the latest tag. If not prompt which is the latest tag.
  2. With that data we can fill the version in [tool.commitizen].
  3. Detect if the tag begins with v or not and define the tag_format in [tool.commitizen]
  4. Find files with a reference to the latest version and define the files in [tool.commitizen], we could let the user choose which files from the found should be added (with a multi-choice from questionary).
  5. Ask to the user if they want the changelog to be generated from scratch if not present.

This is my initial draft, I'm not sure what else could be detected. Potentially we could ask for every configuration, but it's important to keep it short. It's not about customizing, but initializing quickly. If the user wants to customize more -> read the docs.

Activity

  1. changed the title [-]New command init[/-] [+]New command: cz init[/+] on Nov 15, 2019
  2. Lee-W commented on Nov 19, 2019

    @Lee-W
    Member

    I'm working on it.
    init_command

    It seems to me adding "name" in the init step is also a reasonable option.
    Currently, I'm not sure how "files" should be implemented. Do a text search no the whole project to find version is defined in which files do not seem to be a good way.

  3. woile commented on Nov 20, 2019

    @woile
    MemberAuthor

    Yes, the name should be added, and should use as options the available rules (even the plugins). It shouldn't be a problem

    We could search in the current directory and inside a folder called src or like the project name (for this project would be commitizen), and make it not recursively.

    .
    src/
    commitizen/
    

    And in the future if we found it can be improved we improve it.
    But I think with this we would cover a lot of projects in different langugaes.

  4. Lee-W commented on Nov 22, 2019

    @Lee-W
    Member

    It seems to me we might refactor part of the config so that this enhancement can be finished. One of the problems I encounter now is that I'm not able to distinguish the default config and config load from files.
    My Initial thought is to have a BaseConfig abstract class, DefaultConfig, TomlConfig. The difference in each child class will be how to parse config so that we might be able to support other common data formats. I think json would be a good choice. It's commonly used and not as hard to handle as ini does.

    As for the version_files, do you mean code like glob.glob('*version*') and glob.glob(*/*version*) ?

  5. woile commented on Nov 22, 2019

    @woile
    MemberAuthor

    Fine by me, let's give it a try, I think the config part needs some love.

    Regarding the version_files I was thinking more like:

    1. ls src/ ls . ls commitizen (maybe using os.walk or os.listdir)
    2. Get the files only (ignore directories).
    3. Search for the current_version (selected in the first step), inside the files. This doesn't need to be super fast, we can show a Searching for version files... with some sort of animation. It could be a function yielding the files found with a timeout of 5 secs.

    Edit: it's also something that doesn't need to be in the first version of init

  6. Lee-W commented on Nov 23, 2019

    @Lee-W
    Member

    Maybe we can discuss more on the "vesrion_files" part in the future, I'll first work on the refactoring and other functionaility of init.

  7. added a commit that references this issue on Dec 30, 2019
  8. woile commented on Dec 30, 2019

    @woile
    MemberAuthor

    Released on 1.12.0 🎉

  9. rnc commented on Dec 31, 2019

    @rnc

    @woile Isn't init missing from the top level readme? It also seems to be missing when running -h ?

  10. woile commented on Dec 31, 2019

    @woile
    MemberAuthor

    Indeed it's missing in the README, but it works fine with -h. Check that you have the latest version python3 -m pip install -U commitizen

  11. rnc commented on Jan 1, 2020

    @rnc

    @woile Apologies I hadn't refreshed the install to get the -h working. Doh!

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