callowayproject/bump-my-version

Crashing after switch to subprocess

rgryta opened this issue · 1 comments

  • bump-my-version version: 0.17.0
  • Python version: 3.11.5
  • Operating System: MacOS Sonoma

Description

Situation is the same as in the issue #108 - crash after updating the listed file, but before making a commit.
Downgrading back to version 0.16.2 resolves it.

What I Did

Traceback (most recent call last):
  File ".../bin/bump-my-version", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File ".../site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File ".../site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../site-packages/bumpversion/cli.py", line 315, in bump
    do_bump(version_part, new_version, config, found_config_file, dry_run)
  File ".../site-packages/bumpversion/bump.py", line 104, in do_bump
    commit_and_tag(config, config_file, configured_files, ctx, dry_run)
  File ".../site-packages/bumpversion/bump.py", line 134, in commit_and_tag
    config.scm_info.tool.commit_to_scm(list(commit_files), config, ctx, extra_args, dry_run)
  File ".../site-packages/bumpversion/scm.py", line 169, in commit_to_scm
    cls.commit(
  File ".../site-packages/bumpversion/scm.py", line 68, in commit
    subprocess.run(cmd, env=env, capture_output=True, check=True)  # noqa: S603
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../.pyenv/versions/3.11.5/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../.pyenv/versions/3.11.5/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File ".../.pyenv/versions/3.11.5/lib/python3.11/subprocess.py", line 1870, in _execute_child
    env_list.append(k + b'=' + os.fsencode(v))
                               ^^^^^^^^^^^^^^
  File "<frozen os>", line 812, in fsencode
TypeError: expected str, bytes or os.PathLike object, not NoneType
make: *** [bump_patch] Error 1

I've found that it's caused by missing current version within the context provided to the subprocess environment. PR with a quick fix:
#132