markchalloner / git-semver

Git plugin for Semantic Versioning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version prefix not applying to current version in plugins

srt4rulez opened this issue · comments

Using the example plugin without modification, the "current version" argument doesn't contain VERSION_PREFIX config setting.

See output:

$ git semver minor

User plugin "example.sh":

  New version: v0.2.0
  Current version: 0.1.0
  ...
v0.2.0

Notice how "current version" is "0.1.0" while new version is "v0.2.0" (with v)

This seems to be because the version-do method is being called without the VERSON_PREFIX for $version in version-major, version-minor, and version-patch :

version-do "$new" "$version"

I can make a PR.

Thanks for the report. Looking at the code it seems like version-get's return would be the natural place to prefix this.

I can make a PR.

Yes please.

Right, that was my first thought as well, but then the checks for a blank version in patch, minor, and major will possibly never be true (if a version prefix is set)

git-semver/git-semver.sh

Lines 156 to 161 in d838cb3

local version=$(version-get)
# shellcheck disable=SC2155
local major=$(version-parse-major "${version}")
if [ "" == "$version" ]
then
local new=${VERSION_PREFIX}1.0.0

Unless we strip off the version prefix for that check?

@srt4rulez the checks would still be valid, version-get returns without echoing if it can't parse out a valid version.

Yes, I noticed that after doing some tests. I see you pulled in #27, which has some major changes.

This seems to be fixed from #33.