Skip to content

When a published gem using GVB is used inside another repo it crashes runtime. #22

@RoyWarps

Description

@RoyWarps

I maintain a number of tools which manage builds. These tools are versioned using GVB and these tools are run inside another repo to perform a number of tasks.
To avoid using the git tags from the repo in which the published gem is being run the production code uses GVB.gem_version to make sure the version is retrieved from the gemspec and not the git tag.
However during requiring of git_version_bump version.rb https://github.com/mpalmer/git-version-bump/blob/d07b7a7623b65315bd0d893ab218e36ac1423c5c/lib/git-version-bump/version.rb still performs a call to GVB.version which will use the git tags.
In some cases the format of the git tags is wrong resulting in a crash as shown below. In other cases the format may be correct but it will show the version of that tag in that particular repo and not the actual version of the gem being run.

/var/workspace/branch_name/.gem/gems/git-version-bump-0.18.0/lib/git-version-bump.rb:49:in `major_version': sync (part of "sync.tag.1234.1234") is not a numeric version component.  Abandon ship! (ArgumentError)
	from /var/workspace/branch_name/.gem/gems/git-version-bump-0.18.0/lib/git-version-bump/version.rb:3:in `<module:GitVersionBump>'
	from /var/workspace/branch_name/.gem/gems/git-version-bump-0.18.0/lib/git-version-bump/version.rb:1:in `<top (required)>'
	from /var/workspace/branch_name/.gem/gems/git-version-bump-0.18.0/lib/git-version-bump.rb:357:in `require'
	from /var/workspace/branch_name/.gem/gems/git-version-bump-0.18.0/lib/git-version-bump.rb:357:in `<top (required)>'
	from /var/workspace/branch_name/lib/super_build_tool/command.rb:5:in `require'
	from /var/workspace/branch_name/lib/super_build_tool/command.rb:5:in `<top (required)>'
	from /var/workspace/branch_name/lib/super_build_tool.rb:2:in `require'
	from /var/workspace/branch_name/lib/super_build_tool.rb:2:in `<top (required)>'
	from /var/workspace/branch_name/bin/super_build_tool:6:in `require'
	from /var/workspace/branch_name/bin/super_build_tool:6:in `<main>'

Why are the constants in version.rb being populated require time?
I had a look but I was unable to find instance inside the GVB library where these constants are being used.
The way these constants are being defined during requiring can also cause them to be redefined if the gem is required multiple times, resulting in warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions