Repository navigation
Handle string repository and string authors in bower.json (fixes #5543) - #5544
Open
muskan-creates352 wants to merge 1 commit into
Open
muskan-creates352 wants to merge 1 commit into
muskan-creates352 wants to merge 1 commit into
Conversation
…tcode-org#5543) Signed-off-by: Muskan Kumari <er.muskan09@gmail.com>
This branch has not been deployed
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.
Summary
This PR fixes an unhandled
AttributeError: 'str' object has no attribute 'get'inBowerJsonHandlerwhenrepositoryis defined as a string, ensuresvcs_urlis retained whenrepositoryis an object without atypefield, and prevents stringauthorsfrom being split into single-character parties (fixes #5543).Problem
In
src/packagedcode/bower.py:According to the Bower JSON specification,
repositorycan be aStringor anObject. When it is a string (e.g."https://github.com/owner/repo.git"), callingrepository.get('type')crashes withAttributeError.Furthermore, when
repositoryis an object with onlyurl(notype),vcs_urlwas dropped because ofif repo_type and repo_url:.The specification also defines
authorsasArray of (String or Object) or String. Whenauthorsis a string (e.g."authors": "Jane Doe"),for author in authors:iterated over individual characters, creating separatePartyentries for every single letter (Party(name='J'),Party(name='a'), etc.).Changes
src/packagedcode/bower.py:repositoryis astrordict. Ifstr, setvcs_url = repository. Ifdict, extracttypeandurl, falling back tourliftypeis missing.authorsinto a list if it is passed as a string or dict, and also acceptauthor(singular).tests/packagedcode/test_bower.py:repository.repositorywithouttype.authors.authorkey.test_bower.pypass.