You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error "fatal: unknown refname: format lstrip=2" raised when running "cz bump" #1032
When running cz bump , I'm getting the following output:
> cz bump --yes --retry
bump: version 0.1.0 → 0.2.0
tag to create: v0.2.0
increment detected: MINOR
fatal: unknown refname: format lstrip=2
I've been investigating about and it looks like the problem is when commitizen try to fetch the git tags from the repository, specifically in the command statement executed at the file commitizen/git.py:180.
Basically, the translated command is:
git tag --format="%(refname:lstrip=2)---inner_delimiter---%(objectname)---inner_delimiter---%(committerdate:format:%Y-%m-%d)" --sort=-committerdate
The problem goes away if I use strip instead of lstrip. Interesting enough, strip can be used as a synonym to lstrip, according to Git's official documentation.
Steps to reproduce
Run cz bump --yes --retry
Current behavior
The problem occurs when trying to run the command git tag --format="%(refname:lstrip=2)---inner_delimiter---%(objectname)---inner_delimiter---%(committerdate:format:%Y-%m-%d)" --sort=-committerdate because of the lstrip option, which is not recognized
Desired behavior
Getting the list of git tags and finishing the execution normally
Screenshots
No response
Environment
cz version: 3.20.0
python --version: 3.9.7
python3 -c "import platform;print(platform.system())": Linux
git --version: 2.7.4
bash cz version --report:
/var/sds/packages/bin/cz`: line 3: import: command not found
/var/sds/packages/bin/cz: line 4: import: command not found
/var/sds/packages/bin/cz: line 5: from: command not found
/var/sds/packages/bin/cz: cz: line 7: syntax error near unexpected token `('
/var/sds/packages/bin/cz: cz: line 7: ` sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])'
I just tested it on my end. The results of strip and lstrip are the same. But before we actually make this change. @yolave Do you know why lstrip does not work on your side?
I'm actually good with changing it. @noirbizarre@woile Do you see any potential risk on this one?
Thanks for your reply @Lee-W . For adding more context to the post, I'm working on a legacy system with very old dependencies and Git is one of them (version 2.7.4). My bet is the option lstrip was introduced in a later version, so it is not recognized as a valid option when running along with refname.
As I said in the first post, instead, I tried with strip and it worked like a charm.
Activity
[-]Error when running cz bump[/-][+]Error "fatal: unknown refname: format lstrip=2" raised when running "cz bump"[/+]Lee-W commentedon May 20, 2024
I just tested it on my end. The results of
stripandlstripare the same. But before we actually make this change. @yolave Do you know whylstripdoes not work on your side?I'm actually good with changing it. @noirbizarre @woile Do you see any potential risk on this one?
yolave commentedon May 23, 2024
Thanks for your reply @Lee-W . For adding more context to the post, I'm working on a legacy system with very old dependencies and Git is one of them (version 2.7.4). My bet is the option
lstripwas introduced in a later version, so it is not recognized as a valid option when running along withrefname.As I said in the first post, instead, I tried with
stripand it worked like a charm.Lee-W commentedon May 27, 2024
@yolave Thanks for your update! I'm good with this.
fix(git): replace lstrip with strip for compatibility issue
fix(git): replace lstrip with strip for compatibility issue
fix(git): replace lstrip with strip for compatibility issue
fix(git): replace lstrip with strip for compatibility issue
fix(git): replace lstrip with strip for compatibility issue