packagedcode: fix gemspec version constants being stored as-is#4810
Open
kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
Open
packagedcode: fix gemspec version constants being stored as-is#4810kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
kumarasantosh wants to merge 2 commits intoaboutcode-org:developfrom
Conversation
When a gemspec uses a Ruby constant for the version field like: s.version = Elasticsearch::API::VERSION s.version = Faraday::VERSION scancode was storing the constant name as the version string. These constants cannot be resolved without executing Ruby code. Add is_ruby_version_constant() to detect Ruby constant expressions (containing :: namespace separator or bare uppercase constant names) and return None for the version instead of storing an unresolvable constant string. Also fixes the download_url and api_data_url which were generating invalid URLs with the constant name embedded. Fixes aboutcode-org#3129 Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
Signed-off-by: kumarasantosh <santosh.pulikond02@gmail.com>
51c853d to
f8d1c47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3129
This updates gemspec parsing so unresolved Ruby version constants such as Elasticsearch::API::VERSION, Excon::VERSION, and Faraday::VERSION are not stored as literal package versions.
This adds an is_ruby_version_constant() helper in spec.py that detects these unresolvable constants and sets version to None instead of storing the literal constant string.