Catch differences in git URLs in npm state

There is a case where a salt user might specify git://foo/bar
but the npm package might believe it lives at git://foo/bar.git

This attempts to normalize and account for that difference.
This commit is contained in:
Mike Place 2016-11-15 15:34:25 +13:00
parent 1c2d6ff293
commit 0e3bc2366a
No known key found for this signature in database
GPG key ID: 9136F4F13705CFD3

View file

@ -130,12 +130,16 @@ def installed(name,
for pkg_details in installed_pkgs.values():
try:
pkg_from = pkg_details.get('from', '').split('://')[1]
# Catch condition where we may have specified package as
# git://github.com/foo/bar but packager describes it as
# git://github.com/foo/bar.git in the package
if not pkg_from.endswith('.git') and pkg_name.startswith('git://'):
pkg_from += '.git'
if pkg_name.split('://')[1] == pkg_from:
return True
except IndexError:
pass
return False
for pkg in pkg_list:
pkg_name, _, pkg_ver = pkg.partition('@')
pkg_name = pkg_name.strip()