mbarkhau / bumpver

BumpVer: Automatic Versioning
https://github.com/mbarkhau/bumpver
MIT License
191 stars 36 forks source link

Cannot bump version #57

Closed rgreinho closed 5 years ago

rgreinho commented 5 years ago

I was experimenting with pycalver before using it in my projects, but unfortunately I was not able to bump the version number, and got the following output:

INFO    - Old Version: 19.03.0
INFO    - New Version: 19.03.1
INFO    - git commit --file /var/folders/nc/5sdcykxd01x_pkjyh0dkvgpr0000gp/T/tmphovoja_0
Traceback (most recent call last):
  File "/private/tmp/calver-test/venv/bin/pycalver", line 11, in <module>
    sys.exit(cli())
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/pycalver/__main__.py", line 272, in bump
    _bump(cfg, new_version, allow_dirty)
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/pycalver/__main__.py", line 215, in _bump
    _vcs.commit('bump version to {0}'.format(new_version))
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/pycalver/vcs.py", line 130, in commit
    self('commit', env=env, path=tmp_file.name)
  File "/private/tmp/calver-test/venv/lib/python3.7/site-packages/pycalver/vcs.py", line 64, in __call__
    output_data = sp.check_output(cmd_str.split(), env=env, stderr=sp.
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'commit', '--file', '/var/folders/nc/5sdcykxd01x_pkjyh0dkvgpr0000gp/T/tmphovoja_0']' returned non-zero exit status 1.

Extra info

Repro steps

cd /tmp
mkcd calver-test
git init
python3 -m venv venv
source venv/bin/activate
pip install pycalver
pip install --upgrade pip
touch setup.cfg && pycalver init
pycalver bump --dry --no-fetch --patch
pycalver bump --no-fetch --patch

Configuration file:

[pycalver]
current_version = "19.03.0"
version_pattern = "{yy}.{month}.{PATCH}"
commit = True
tag = True
push = True

[pycalver:file_patterns]

Environment:

$ pycalver --version
pycalver, version v201902.0027
$ system_profiler SPSoftwareDataType|grep macOS | xargs
System Version: macOS 10.14.3 (18D109)
mbarkhau commented 5 years ago

Thank you for the detailed report :100:

I will look into this perhaps later today, but latest on Thursday.

rgreinho commented 5 years ago

I just tried running it in a docker container, but I experienced the same issue:

$ docker run -it --rm -v $PWD:/usr/src/app pycalver:latest bump --no-fetch --patch
INFO    - Old Version: 19.03.0
INFO    - New Version: 19.03.1
INFO    - git commit --file /tmp/tmpamdsdox_
Traceback (most recent call last):
  File "/usr/local/bin/pycalver", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pycalver/__main__.py", line 272, in bump
    _bump(cfg, new_version, allow_dirty)
  File "/usr/local/lib/python3.7/site-packages/pycalver/__main__.py", line 215, in _bump
    _vcs.commit('bump version to {0}'.format(new_version))
  File "/usr/local/lib/python3.7/site-packages/pycalver/vcs.py", line 130, in commit
    self('commit', env=env, path=tmp_file.name)
  File "/usr/local/lib/python3.7/site-packages/pycalver/vcs.py", line 64, in __call__
    output_data = sp.check_output(cmd_str.split(), env=env, stderr=sp.
  File "/usr/local/lib/python3.7/subprocess.py", line 389, in check_output
    **kwargs).stdout
  File "/usr/local/lib/python3.7/subprocess.py", line 481, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'commit', '--file', '/tmp/tmpamdsdox_']' returned non-zero exit status 128.

Dockerfile:

FROM python:3.7.1-alpine

WORKDIR /usr/src/app
RUN apk add --update --no-cache git openssh-client \
    && pip install --no-cache-dir pycalver

ENTRYPOINT ["pycalver"]

Built with docker build -t pycalver ..

So I think we can safely assume it is not an OS issue.

An idea may be to use git commit -m {my message in a str} instead of using the temporary file.

mbarkhau commented 5 years ago

The issue does not appear to be related to the use of the temporary file for the commit. Rather, I think the issue is that the commit is empty because no files have been added. Of course that shouldn't result in a stacktrace like it does, so I'll improve the error message and hopefully it should be clear how to proceed.

mbarkhau commented 5 years ago

I hope your issue is resolved with v201903.0028