mtkennerly / dunamai

Dynamic versioning library and CLI
https://dunamai.readthedocs.io/en/latest
MIT License
321 stars 23 forks source link

`RuntimeError` when calling `Version.from_any_vcs()` in newly-cloned repository #18

Closed ghost closed 3 years ago

ghost commented 3 years ago

I called Version.from_any_vcs().serialize() in a newly cloned repository (specifically https://github.com/JaimeCalzadaNOAA/adcircpy), but get error: unknown option 'merged'

(coupledmodeldriver) Orion-login-2[64] zburnett$ python
Python 3.8.2 (default, Mar 25 2020, 17:03:02)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from dunamai import Version
>>> Version.from_any_vcs().serialize()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zburnett/miniconda3/envs/coupledmodeldriver/lib/python3.8/site-packages/dunamai/__init__.py", line 865, in from_any_vcs
    return cls._do_vcs_callback(vcs, pattern, latest_tag, tag_dir)
  File "/home/zburnett/miniconda3/envs/coupledmodeldriver/lib/python3.8/site-packages/dunamai/__init__.py", line 906, in _do_vcs_callback
    return mapping[vcs](**kwargs)
  File "/home/zburnett/miniconda3/envs/coupledmodeldriver/lib/python3.8/site-packages/dunamai/__init__.py", line 500, in from_git
    code, msg = _run_cmd(
  File "/home/zburnett/miniconda3/envs/coupledmodeldriver/lib/python3.8/site-packages/dunamai/__init__.py", line 76, in _run_cmd
    raise RuntimeError(
RuntimeError: The command 'git for-each-ref "refs/tags/*" --merged HEAD --format "%(refname)@{%(objectname)@{%(creatordate:iso-strict)@{%(*committerdate:iso-strict)@{%(taggerdate:iso-strict)"' returned code 129. Output:
error: unknown option `merged'
usage: git for-each-ref [options] [<pattern>]

    -s, --shell           quote placeholders suitably for shells
    -p, --perl            quote placeholders suitably for perl
    --python              quote placeholders suitably for python
    --tcl                 quote placeholders suitably for tcl

    --count <n>           show only <n> matched refs
    --format <format>     format to use for the output
    --sort <key>          field name to sort on

this appears to be from the following lines: https://github.com/mtkennerly/dunamai/blob/22cdbfc7f76e3432809f34a6d95ad943554538d7/dunamai/__init__.py#L500-L508

ghost commented 3 years ago

oh never mind, it's because the version of Git on this machine is 1.8.3.1, and the current version is 2.25.1

ghost commented 3 years ago

I assume that this project doesn't want to support arbitrary old versions of Git (I wouldn't) so I'll just close this issue

mtkennerly commented 3 years ago

The minimum version currently is 2.7.0. If there were a super simple drop-in replacement for earlier compatibility, I'd be open to it, but it can definitely get complicated trying to be too compatible 😅