- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 302
Closed
Labels
issue-status: pr-createdpr-status: wait-for-modificationtype: featureA new enhacement proposalA new enhacement proposal
Description
Description
cz commit is very good tool.
If prepare-commit-msg hook calls cz commit, become easy to commit by many user.
Possible Solution
like cz check, writing pre-commit config
---
repos:
- hooks:
  - id: commitizen-prepare-commit-msg
    stages: [prepare-commit-msg]and user type git comit, then prepare-commit-msg hook works and invokes cz commit.
Is this feature accepted as this product policy?
Additional context
I did a basic research. And I found that there are two issues.
- The current cz commit calls git. But in this case, git calls cz commit
- Git hook is started without standard input, so we can't create commit message interactively
I made a test implementation to solve the problem by the following method
- When called from git, write the commit message to the file which is set by "--commit-msg-file" argument
- Open tty manualy and use as stdio.
but this change has sideffect.
tty is manually opened as io.FileIO.
But prompt_toolkit (which used by questionary) assumes tty is opened as io.TextIOWrapper.
As a workaround  I added wrap class
class WrapStdin:
    def __init__(self):
        fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY)
        tty = open(fd, "wb+", buffering=0)
        self.tty = tty
    def __getattr__(self, key):
        if key == "encoding":
            return "UTF-8"
        return getattr(self.tty, key)
    def __del__(self):
        self.tty.close()All patch code is here.
saygox@033159d
josix, muhlba91, nickbroon and marcel-mattr
Metadata
Metadata
Assignees
Labels
issue-status: pr-createdpr-status: wait-for-modificationtype: featureA new enhacement proposalA new enhacement proposal