Skip to content

cz init does not work as intended when run programmatically #1290

Open
@Coinhexa

Description

@Coinhexa

Description

  • cz init does not work properly when run programmatically inside the python:3.10.11 docker container
  • I am trying to run cz init from a bash script without manual intervention and I tried various formats with no luck so far

Steps to reproduce

  1. Install docker
  2. docker pull python:3.10.11
  3. Install poetry inside docker
curl -sSL https://install.python-poetry.org | python3 - --version 1.6.0
  1. Install commitizen docker
  2. Try running cz init programmatically inside docker as shown below

Run a docker container with python:3.10.11

Method 1

printf "\npyproject.toml\ncz_conventional_commits\npoetry: Get and set version from pyproject.toml:tool.poetry.version field\nsemver\nv\$major.\$minor.\$patch\$prerelease\nY\nY\ncommit-msg" | poetry run cz init

Method 2

poetry run cz init <<EOF
pyproject.toml
cz_conventional_commits
poetry: Get and set version from pyproject.toml:tool.poetry.version field
semver
v\$major.\$minor.\$patch\$prerelease
Y
Y
commmit-msg
EOF

Current behavior

Method 1

printf "\npyproject.toml\ncz_conventional_commits\npoetry: Get and set version from pyproject.toml:tool.poetry.version field\nsemver\nv$major.$minor.$patch$prerelease\nY\nY\ncommit-msg" | /root/.local/bin/poetry run cz init

Output 1

Welcome to commitizen!

Answer the questions to configure your project.
For further configuration visit:

https://commitizen-tools.github.io/commitizen/config/

Warning: Input is not a terminal (fd=0).
? Please choose a supported config file:  pyproject.toml
? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_customize
? Choose the source of the version: poetry: Get and set version from pyproject.toml:tool.poetry.version field
No Existing Tag. Set tag to v0.0.1
? Choose version scheme:  semver
? Please enter the correct version format: (default: "$version") semver
? Create changelog automatically on bump Yes
? Keep major version zero (0.x) during breaking changes Yes
? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) done

You can bump the version running:

	cz bump

Configuration complete 🚀

Method 2

poetry run cz init <<EOF
pyproject.toml
cz_conventional_commits
poetry: Get and set version from pyproject.toml:tool.poetry.version field
semver
v\$major.\$minor.\$patch\$prerelease
Y
Y
commmit-msg
EOF

Output 2

Welcome to commitizen!

Answer the questions to configure your project.
For further configuration visit:

https://commitizen-tools.github.io/commitizen/config/

Warning: Input is not a terminal (fd=0).
? Please choose a supported config file:  .cz.toml
? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits
? Choose the source of the version: scm: Fetch the version from git and does not need to set it back
No Existing Tag. Set tag to v0.0.1
? Choose version scheme:  pep440
? Please enter the correct version format: (default: "$version") v$major.$minor.$patch$prerelease
? Create changelog automatically on bump Yes
? Keep major version zero (0.x) during breaking changes Yes
? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) done

You can bump the version running:

	cz bump

Configuration complete 🚀

Desired behavior

Both outputs should be as follows

Welcome to commitizen!

Answer the questions to configure your project.
For further configuration visit:

https://commitizen-tools.github.io/commitizen/config/

? Please choose a supported config file:  pyproject.toml
? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits
? Choose the source of the version: poetry: Get and set version from pyproject.toml:tool.poetry.version field
No Existing Tag. Set tag to v0.0.1
? Choose version scheme:  semver
? Please enter the correct version format: (default: "$version") v$major.$minor.$patch$prerelease
? Create changelog automatically on bump Yes
? Keep major version zero (0.x) during breaking changes Yes
? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) [commit-msg]
commitizen pre-commit hook is now installed in your '.git'


You can bump the version running:

	cz bump

Configuration complete 🚀

Screenshots

No response

Environment

commitizen version: 3.30.0
python version: 3.10.11
docker version: Docker version 27.2.0, build 3ab4256
cz init is running inside a docker container very specifically the python 3.10.11 container

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions