Skip to content

Commit 68ffc5c

Browse files
author
Li
committed
#395 update vcs type and make sure it covers all possible types
1 parent 415a9c5 commit 68ffc5c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/packagedcode/phpcomposer.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
from __future__ import print_function
2727

2828
import codecs
29+
import logging
30+
import json
2931
from collections import OrderedDict
3032
from functools import partial
31-
import json
32-
import logging
33+
3334

3435
from commoncode import filetype
3536
from commoncode import fileutils
@@ -98,6 +99,7 @@ def parse(location):
9899

99100
if not data.get('name') or not data.get('description'):
100101
# a composer.json without name and description is not a usable PHP composer package
102+
# name and description fields are required: https://getcomposer.org/doc/04-schema.md#name
101103
return
102104

103105
package = PHPComposerPackage()
@@ -122,7 +124,7 @@ def parse(location):
122124
value = value.strip()
123125
if value:
124126
func(value, package)
125-
vendor_mapper(package) # Parse vendor from name value
127+
vendor_mapper(package) # Parse vendor from name value
126128
return package
127129

128130

@@ -253,13 +255,15 @@ def repository_mapper(repos, package):
253255
elif isinstance(repos, list):
254256
for repo in repos:
255257
if repo.get('type') == 'vcs':
258+
# vcs type includes git, svn, fossil or hg.
259+
# refer to https://getcomposer.org/doc/05-repositories.md#vcs
256260
repo_url = repo.get('url')
257-
if repo_url.startswith('svn'):
261+
if repo_url.startswith('svn') or 'subversion.apache.org' in repo_url:
258262
package.vcs_tool = 'svn'
259-
elif repo_url.startswith('hg'):
263+
elif repo_url.startswith('hg') or 'mercurial.selenic.com' in repo_url:
260264
package.vcs_tool = 'hg'
261-
elif repo_url.startswith('cvs'):
262-
package.vcs_tool = 'cvs'
265+
elif repo_url.startswith('fossil') or 'fossil-scm.org' in repo_url:
266+
package.vcs_tool = 'fossil'
263267
else:
264268
package.vcs_tool = 'git'
265269
package.vcs_repository = parse_repo_url(repo.get('url'))

0 commit comments

Comments
 (0)